Ok, so this one baffles me. I'm trying to get a script to do internal speed tests on demand. I'm using iperf. The bash commands are below.
Code:
#!/bin/bash
set -ax
desktoppath="/home/buee/Desktop"
iperfserver=192.168.111.230
killfile="/home/buee/Desktop/Kill.txt"
echo
echo "Please input the customer's name..."
read customer
clear
ssh buee@$iperfserver < $killfile
ssh buee@$iperfserver "iperf -s"
sleep 2
xterm -e "iperf -c $iperfserver -t 20 -i 2 -r -d > $desktoppath/$customer"
sleep 2
kill `ps aux | grep iperf | awk '{print $2}' | head -1`
ssh buee@$iperfserver < $killfile
ssh buee@$iperfserver "iperf -s -u" &
sleep 2
xterm -e "iperf -c -u $iperfserver -t 20 -i 2 -r -d >> $desktoppath/$customer"
sleep 2
kill `ps aux | grep iperf | awk '{print $2}' | head -1`
ssh buee@$iperfserver < $killfile
exit 0
The first portion:
Code:
ssh buee@$iperfserver < $killfile
ssh buee@$iperfserver "iperf -s"
sleep 2
xterm -e "iperf -c $iperfserver -t 20 -i 2 -r -d > $desktoppath/$customer"
sleep 2
kill `ps aux | grep iperf | awk '{print $2}' | head -1`
ssh buee@$iperfserver < $killfile
works beautifully, no issues at all.
But the second part:
Code:
ssh buee@$iperfserver "iperf -s -u" &
sleep 2
xterm -e "iperf -c -u $iperfserver -t 20 -i 2 -r -d >> $desktoppath/$customer"
sleep 2
kill `ps aux | grep iperf | awk '{print $2}' | head -1`
ssh buee@$iperfserver < $killfile
Gives me this:
Code:
+ ssh buee@192.168.111.230 'iperf -s -u'
+ ssh buee@192.168.111.230 'bg 1'
------------------------------------------------------------
Server listening on UDP port 5001
Receiving 1470 byte datagrams
UDP buffer size: 112 KByte (default)
------------------------------------------------------------
bash: line 0: bg: no job control
+ sleep 2
+ xterm -e 'iperf -c -u 192.168.111.230 -t 20 -i 2 -r -d >> /home/buee/Desktop/Test'
+ sleep 2
++ ps aux
++ grep iperf
++ awk '{print $2}'
++ head -1
+ kill 3420
The only difference between the iperf command in portion A and portion B is B has a -u switch in there that will test with UDP protocol. I figured since I got some output, I'd try sending the command to the back. This process will not go to the background. I tried tacking a '&' to the end of it, I tried following it up with a 'bg 1' through SSH immediately after, I tried "iperf -s -u && bg" as well as "... && bg 1", I tried opening it in a different terminal window on the remote machine, I tried opening it on a different bash shell on the remote machine, nothing seems to help. The following command issued on the local machine completes in less than a second, but it doesn't make sense because it's not picking up a server on the other side of the connection, it should at least have a few seconds to timeout, not just proceed. Any ideas?