Run MPI program with QProcess - mpi

I have a problem trying to using MPI in QProcess. Here is the code:
mpiexec.hydra -n 2 ip1,ip2 (program) params...
it works when i use the terminal, but doesn't work when using QProcess, the code in QProcess:
QProcess p;
p.start("mpiexec.hydra -n 2 ip1,ip2 (program) params...");
is there something i need to set when using QProcess?
it works in windows, but failed in linux,
and it works when there's only local ip in it.
Thanks everybody for your help.

Related

paramiko and nohup ''

OK so I have paramiko v2.2.1 and I am trying to login to a machine and restart a service. Inside the service scripts it basically starts a process via nohup. However if I allow paramiko to disconnect as soon as it is done the process started terminates with a PIPE signal when it writes to stdout.
If I start the service by ssh'ing into the box and manually starting it there is no issue and it runs in the background fine. Also if I add long sleep 10 before disconnecting (close) paramiko it also seems to work just fine.
The service is started via a init.d script via a line like this:
env LD_LIBRARY_PATH=$bin_path nohup $bin_path/ServerLoop.sh \
"$bin_path/Service service args" "$#" &
Where ServerLoop.sh simply calls the service forever in a loop like this so it will never die:
SERVER=$1
shift
ARGS=$#
logger $ARGS
while [ 1 ]; do
$SERVER $ARGS
logger "$SERVER terminated with exit code: $STATUS. Server has been restarted"
sleep 1
done
I have noticed when I start the service by ssh'ing into the box I get a nohup.out file written to the root. However when I run through paramiko I get no nohup.out written anywhere on the system ... ie this after I manually ssh into the box and start the service:
root#ts4700:/mnt/mc.fw/bin# find / -name "nohup*"
/usr/bin/nohup
/usr/share/man/man1/nohup.1.gz
/nohup.out
And this is after I run through paramiko:
root#ts4700:/mnt/mc.fw/bin# find / -name "nohup*"
/usr/bin/nohup
/usr/share/man/man1/nohup.1.gz
As I understand it nohup will only redirect the output to nohup.out if "If standard output is a terminal" (from the manual), otherwise it thinks it is saving the output to a file so it does not redirect. Hence I tried the following:
In [43]: import paramiko
In [44]: paramiko.__version__
Out[44]: '2.2.1'
In [45]: ssh = paramiko.SSHClient()
In [46]: ssh.set_missing_host_key_policy(AutoAddPolicy())
In [47]: ssh.connect(ip, username='root', password=not_for_so_sorry, look_for_keys=False, allow_agent=False)
In [48]: stdin, stdout, stderr = ssh.exec_command("tty")
In [49]: stdout.read()
Out[49]: 'not a tty\n'
So I am thinking that nohup is not redirecting to nohup.out when I run it through paramiko because tty is not returning a terminal. I don't know why adding a sleep(10) would fix this though as the service if run on the command line is quite verbose.
I have also noticed that if the service is started from a manual ssh its tty in the ps ax output is still set to the ssh tty ... however if the process is started by paramiko its tty in the ps ax output is set to "?" .. since both processes are run through nohup I would have expected this to be the same.
If the problem is that nohup is indeed not redirecting the output to nohup.out because of the tty is there a way to force this to happen or a better way to run this sort of command via paramiko?
Thanks all, any help with this would be great :)

printing gatttool notification data in file

I am running sensortag 2650 to read notification from sensor to my computer.I am using gatttool (bluez) to do this.My output gets displayed on the console, while the sensor is on the run. BTW I am using ubuntu 14.0.4.
Now the issue is I am not able to make the output data get written in a file instead of displaying on the console. I tried the normal re-direct >>/> operator but that doesnt work.
I am using the following link, just that I am using Linux on my system instead of Raspberry Pi.
https://github.com/codeplanner/TI-CC2650-1
Any clue would be highly appreciated.
Thanks,
Shankhadeep
Do the following:
sudo gatttool -b XX:XX:XX:XX:XX:XX >> output.txt
Then the terminal won´t show anything. BUT! type connect and press enter.
Now the bluetoothmodule is paired with your device!
Normaly, everytime when you get a notification, this will be write in the output.txt.
I tested it with my bluetooth module HM-10 and a Raspberry Pi and it works!
I know its 6 years too late but:
what worked for me was sudo gatttool -b XX:XX:XX:XX:XX:XX -I >> output.txt
putty_capture
This is not ideal for me because im only interested in the received raw data not the ascii console dump, but it is what OP asked for...
Another option would be to use hcidump with some filters

Killing ffmpeg from Qt results in a corrupt video file

I'm using Qt to record stream data from a Mobotix camera on Windows 7. The command I use is:
ffmpeg -f mjpeg -i "http://admin:password#192.168.0.100/control/faststream.jpg?stream=full" -c:v libx264 -preset slow -crf 22 -c:a copy out.mp4
This works fine from the command line and when I want to stop it I just do Ctrl-C. But I'm doing this from an application using Qt 5.2 via a QProcess. After 10 minutes I want to stop the recording so I tried QProcess::terminate() but this doesn't stop it. QProcess::kill() works but the resulting video won't play. This answer suggests I'm doing it the right way.
I connect to QProcess::finished() so when I call QProcess::kill() the result is:
int exitCode = 62097
QProcess::ExitStatus exitStatus = QProcess::CrashExit
Apparently this is the return code Qt uses when it kills a process.
So is there any other way for me to either terminate the process gracefully (the same as pressing Ctrl-C) or perform this same functionality via an ffmpeg library so I can stop it properly?
I explain the correct way for handling the same exact issue in that thread:
http://qt-project.org/forums/viewthread/47654/
its very simple all you need is to send q for quit signal this is simple example:
myProcess->setProcessChannelMode(QProcess::ForwardedChannels);
myProcess->write("q");
myProcess->closeWriteChannel();
keep in mind you also have to exit your parent process too... good luck.
Qt doesn't have a portable way to do this. However, you can use QProcess::processId() to get a native process PID which you can use. On POSIX-complitable systems you can use kill(pid, SIGINT) to send a Ctrl-C. Just include signal.h and sys/types.h. On Windows it's harder, look on this question: link

lines not aligned in putty, after a tail -f in a command

I use putty to access my Server Ubuntu.
In the console, when I start a tail -f, everything is fine.
But if I start this from a command (in a shortcut, I write putty.exe -m see_log.txt), the result is horrible :
and not easily readable.
How can I solve it?
Thanks
Enable this function and save as a default setting on your putty configuration:
http://the.earth.li/~sgtatham/putty/0.53b/htmldoc/Chapter4.html#4.3.3

Two instances of BusyBox on separate Serial lines (ttySn)

I am working on an arm board which has two serial ports, accessible through /dev/ttyS0 and /dev/ttyS1.
Busybox runs on /dev/ttyS0.
I am able to write data on /dev/ttyS1 using 'echo' command like so
#echo "microMolvi" > /dev/ttyS1
I was wondering if there is a way to run another instance of busybox(shell) on /dev/ttyS1, so that I may be able to work with two virtual terminals simultaneously.
After some research I found out that the first shell, that runs on ttyS0, was configured to behave so in the /etc/inittab file.
This line in /etc/inittab was responsible for invocation of the default shell at ttyS0:
ttyS0::respawn:/sbin/getty -L ttyS0 38400 vt100 # GENERIC_SERIAL
So, based on my gut feeling, I put a getty on the second serial port by adding the following line in /etc/inittab
ttyS1::respawn:/sbin/getty -L ttyS1 38400 vt100 # GENERIC_SERIAL
It worked like a charm.
Hope this helps someone someday.

Resources