Hello,
I like to begin with :wall:.. literally... It has been 4 days and I have no idea how to fix it.
Environment - AIX 5.3
I wrote a script to call on ssh to log into another box via PKA to do something else.
If I run the script on the terminal, it works 100%. If the SAP customised program calls this script to do the same thing, it works 50% of the time. The other 50% of the time, i get an error.
The problem is that /bin/ssh is sometimes "missing". Weird but true... and amazing...
I've tried specifying PATH, quoting /bin/ssh, and alot of other stuff.....
#!/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin:$PATH; export PATH
SSHCMD="/bin/ssh"
#SSH via PKA login is used to access FSI server
LOGFILE=/var/logs/Log.`date +%d%m%y.%H%I%S`
FILE=$1
printf "Received command to start process\nVariable passed is '$FILE'\nUser ID running this program is
`whoami`\n" > $LOGFILE
#Log into GROUP server via SSH and call second command
printf "\nLogging into GROUP server via SSH\n" >> $LOGFILE
ls -l $SSHCMD >> $LOGFILE 2>&1
$SSHCMD -l AdminX 1.1.1.99 "cmd /c D:/Scripts/DoSomething.bat '$FILE'" >> $LOGFILE 2>&1
printf, echo, ls commands all worked fine 100%. It stops (and only sometimes) because it seems like it could not find ssh...
Log file correctly shows the printf and echo commands but ends with the below
/opt/script/encrypt.sh[15]: /bin/ssh: not found.
I have been trawling the net for days hoping to understand why and have ran out of time.
The bit I wanted to understand most is that why is this script only failing sometimes, but worked other times.
Many thanks in advance.
J Phang
---------- Post updated at 11:44 PM ---------- Previous update was at 11:41 PM ----------
I have also tried to od -xc the log file to be sure that it was not due to characters that were unreadable/invisible. It shouldn't be as well, since such a problem would lead to an error all the time...
Thanks
J Phang