Hi All,
This bash bug is driving me up the wall. A "simple" cheap script
to catch 1 line process descriptions from man pages (usually correct)
such as:
acpid - Advanced Configuration and Power Interface event daemon
My problem:
./pleaseLOOP host3 # quits after 1 iteration (with correct result for that
iteration)
but if I comment off the ssh call at line 23 it runs 3 iterations as expected.
ssh call without the redirection still quits after 1 iteration.
I can not see the problem. (Help)
Thanks,
Chris
cat -n cat -n host3 # file lines are <process> <hostname>
1 acpid host1
2 acpid host2
3 xinetd host3
cat -n pleaseLOOP
1 #!/bin/bash
2 #
3 # query process description from man page
4 #
5 #
6 cmdLOCAL=$(date +%Y%m%d-%H%M%S-$$LOCAL) # unique local name
7 cmdREMOTE=myselfRunScriptRemotely # remote script name
8 echo " cmdLOCAL: ${cmdLOCAL}"
9
10 while read -r -a line # read line into array (space is ele
seperator
11 do
12 procNAME="${line[0]}"; # process name
13 hostNAME="${line[1]}"; # host name
14 #
15 # -- build the command to run remotely Example:
16 # x="$(man acpid | grep acpid | grep \- | head -1)"; echo
procDESC=\"${x}\"
17
18 echo "x=\"\$(man ${procNAME} | grep ${procNAME} | grep \- | head -1)\"; echo procDESC=\\\"\${x}\\\"" >
${cmdREMOTE}
19 chmod +x ${cmdREMOTE}
20
21 #
22 scp ${cmdREMOTE} ${hostNAME}:/tmp/${cmdREMOTE} # copy the script
23 ssh ${hostNAME} /tmp/${cmdREMOTE} > ${cmdLOCAL}; # run the script
24 chmod +x ${cmdLOCAL}
25 echo "===============${cmdLOCAL}"
26 cat ./${cmdLOCAL}
27 echo "===============${cmdLOCAL}"
28 . ./${cmdLOCAL}
29 # fix up NULL procDESC
30 if [ -z "${procDESC}" ]
31 then
32 procDESC="No manual entry for ${procNAME}"
33 fi
34 echo "p: ${procNAME} h: ${hostNAME} d: ${procDESC}"
35 echo " .. end of loop iteration"
36
37 done < $1
38
39 # get rid of it
40 rm -vf ${cmdLOCAL}
41 echo "Debug cat of ${cmdREMOTE}:"
42 cat ${cmdREMOTE}
43 rm -vf ${cmdREMOTE}
_______________________________________________
clug-talk mailing list
[email protected]
http://clug.ca/mailman/listinfo/clug-talk_clug.ca
Mailing List Guidelines (http://clug.ca/ml_guidelines.php)
**Please remove these lines when replying