prepend date to echo commands

This commit is contained in:
john30
2017-08-27 10:50:11 +02:00
parent 0b7fa9d817
commit 6d3abe11b6
Executable → Regular
+15 -15
View File
@@ -91,7 +91,7 @@ if (socket_listen($srv, 5)===false) {
@socket_close($srv); @socket_close($srv);
die("server: listen socket"); die("server: listen socket");
} }
echo "server: waiting\n"; echo `date` "server: waiting\n";
if (($cli=socket_accept($srv))===false) { if (($cli=socket_accept($srv))===false) {
@socket_close($srv); @socket_close($srv);
die("server: socket accept"); die("server: socket accept");
@@ -99,7 +99,7 @@ if (($cli=socket_accept($srv))===false) {
@socket_set_block($cli); @socket_set_block($cli);
$output=""; $output="";
$input=$hexinput=""; $input=$hexinput="";
echo "server: running\n"; echo `date` "server: running\n";
$endtime=time()+15; $endtime=time()+15;
$firstsend=time()+5; $firstsend=time()+5;
$secondsend=$firstsend+5; $secondsend=$firstsend+5;
@@ -167,24 +167,24 @@ while (time()<$endtime) {
} }
@socket_close($cli); @socket_close($cli);
@socket_close($srv); @socket_close($srv);
echo "server: done\n"; echo `date` "server: done\n";
if ($error) { if ($error) {
exit($error); exit($error);
} }
' & ' &
srvpid=$! srvpid=$!
if [ -z "$srvpid" ]; then if [ -z "$srvpid" ]; then
echo "unable to start echo server" echo `date` "unable to start echo server"
exit 1 exit 1
fi fi
sleep 1 sleep 1
ps -p $srvpid >/dev/null ps -p $srvpid >/dev/null
status="$?" status="$?"
if [ ! "$status" = 0 ]; then if [ ! "$status" = 0 ]; then
echo "unable to start echo server" echo `date` "unable to start echo server"
exit 1 exit 1
fi fi
echo "server: $srvpid" echo `date` "server: $srvpid"
cat >contrib/etc/ebusd/test.csv <<EOF cat >contrib/etc/ebusd/test.csv <<EOF
#no column names #no column names
u,broadcast,outsidetemp,,,fe,b516,01,temp2,m,D2B u,broadcast,outsidetemp,,,fe,b516,01,temp2,m,D2B
@@ -210,12 +210,12 @@ echo "test,testpass,installer" > ./passwd
sleep 1 sleep 1
pid=`head -n 1 "$PWD/ebusd.pid"` pid=`head -n 1 "$PWD/ebusd.pid"`
if [ -z "$pid" ]; then if [ -z "$pid" ]; then
echo "unable to start ebusd" echo `date` "unable to start ebusd"
kill $srvpid kill $srvpid
cat "$PWD/ebusd.log" cat "$PWD/ebusd.log"
exit 1 exit 1
fi fi
echo "ebusd: $pid" echo `date` "ebusd: $pid"
kill -1 $pid kill -1 $pid
#client: #client:
readarray lines <<EOF readarray lines <<EOF
@@ -308,14 +308,14 @@ while [ ! "$status" = 0 ]; do
status=$? status=$?
done done
if [ "$status" = 0 ]; then if [ "$status" = 0 ]; then
echo "got signal" echo `date` "got signal"
sleep 5 sleep 5
echo "listen"|./src/tools/ebusctl -p 8877 & echo "listen"|./src/tools/ebusctl -p 8877 &
lstpid=$! lstpid=$!
./src/tools/ebusctl -p 8899 >/dev/null 2>/dev/null ./src/tools/ebusctl -p 8899 >/dev/null 2>/dev/null
for line in "${lines[@]}"; do for line in "${lines[@]}"; do
if [ -n "$line" ]; then if [ -n "$line" ]; then
echo "send: $line" echo `date` "send: $line"
./src/tools/ebusctl -p 8877 $line ./src/tools/ebusctl -p 8877 $line
fi fi
done done
@@ -323,7 +323,7 @@ if [ "$status" = 0 ]; then
./src/tools/ebusctl -p 8877 scan result | egrep -q "still running" ./src/tools/ebusctl -p 8877 scan result | egrep -q "still running"
status=$? status=$?
done done
echo "scan result:" echo `date` "scan result:"
./src/tools/ebusctl -p 8877 scan result ./src/tools/ebusctl -p 8877 scan result
curl -s "http://localhost:8878/data/" >/dev/null curl -s "http://localhost:8878/data/" >/dev/null
curl -s "http://localhost:8878/data/broadcast/?since=1&exact=1&required=" >/dev/null curl -s "http://localhost:8878/data/broadcast/?since=1&exact=1&required=" >/dev/null
@@ -333,7 +333,7 @@ if [ "$status" = 0 ]; then
curl -s "http://localhost:8878/data/?full" >/dev/null curl -s "http://localhost:8878/data/?full" >/dev/null
curl -s "http://localhost:8878/data/mc.5/installparam?poll=1&user=test&secret=testpass" >/dev/null curl -s "http://localhost:8878/data/mc.5/installparam?poll=1&user=test&secret=testpass" >/dev/null
curl -T .travis.yml http://localhost:8878/data/ curl -T .travis.yml http://localhost:8878/data/
echo "commands done" echo `date` "commands done"
kill $lstpid kill $lstpid
fi fi
verify=`./src/tools/ebusctl -p 8877 info|egrep "^address 04:"` verify=`./src/tools/ebusctl -p 8877 info|egrep "^address 04:"`
@@ -341,12 +341,12 @@ if [ "x$verify" != 'xaddress 04: slave #25, scanned "MF=153;ID=BBBBB;SW=3031;HW=
echo "error unexpected result from info command: $verify" echo "error unexpected result from info command: $verify"
kill $pid kill $pid
kill $srvpid kill $srvpid
echo "ebusd log:" echo `date` "ebusd log:"
cat "$PWD/ebusd.log" cat "$PWD/ebusd.log"
exit 1 exit 1
fi fi
kill $pid kill $pid
echo "ebusd log:" echo `date` "ebusd log:"
cat "$PWD/ebusd.log" cat "$PWD/ebusd.log"
echo "done." echo `date` "done."
wait $srvpid wait $srvpid