Sponsored Content
Top Forums Shell Programming and Scripting Command not found in shell script - stumped for 4 days Post 302487720 by plonkagain on Thursday 13th of January 2011 10:44:34 AM
Old 01-13-2011
Command not found in shell script - stumped for 4 days

Hello,

I like to begin with Smilie.. 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.....

Code:
#!/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

Code:
/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
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

List out last 2 days files using shell command

Could please help me To view removed files list for last 2 days. (1 Reply)
Discussion started by: santhakumar
1 Replies

2. Shell Programming and Scripting

perl replace command, stumped!

Ok, I stole some code from a program that takess a hash of a password from PasswdMD5 and replaces it in the /etc/shadown file on a linux system. I run his program and it's fine. Well I took the same code and put it in another program that won't ask for prompgx and such and this code won't work:... (2 Replies)
Discussion started by: benefactr
2 Replies

3. Shell Programming and Scripting

Shell script for purging the 3 days old files

Hi all, I try to write shell script to the below requirement. I have Hard coded the oratab location and take the list of databases from oratab and find out archive log locations for each database, and list more than 3 days old files for each location and purge those. ... (2 Replies)
Discussion started by: mak_boop
2 Replies

4. Shell Programming and Scripting

#!/bin/bash and #1bin/sh command not found error on mac osx terminal/shell script

i am having a weird error on mac os x running some shell scripts. i am a complete newbie at this and this question concerns 2 scripts. one of which a friend of mine wrote (videochecker.sh) a couple weeks ago and it's been running fine on another machine. then last week i wrote capture.sh and it... (2 Replies)
Discussion started by: danpaluska
2 Replies

5. UNIX for Dummies Questions & Answers

Clarification on '1 days ago' in date command [Found answer, posted within]

I know the topic of getting yesterday's date has been covered ad nauseum, but I just want to be clear on something. I recently started using the command date --date='1 days ago' '+%m/%d/%y' to get yesterday's date and it's been working great. I just want to be certain that it is going to... (1 Reply)
Discussion started by: DeCoTwc
1 Replies

6. Shell Programming and Scripting

rm:command not found in linux Bash shell script

Hi All, Linux lxs3er06 2.6.9-67.ELsmp #1 SMP Wed Nov 7 13:58:04 EST 2007 i686 i686 i386 GNU/Linux Issue: While executing shell scripts in bash shell, following error messages are thrown: rm:command not found On doing little investigation, I added '/bin' to $PATH and on doing echo... (9 Replies)
Discussion started by: a1_win
9 Replies

7. Linux

Shell implementation - Command not found

Hi, I am trying to execute a program with pipes to run a few basic commands by forking children. When I try to run commands in the child process without pipe, I am unable to run the command as execv fails. However for commands that are given with pipes execute successfully. for example:... (1 Reply)
Discussion started by: mmurali2
1 Replies

8. Shell Programming and Scripting

Stumped on simple BASH Script

Hello All, First and foremost, if I have posted this question in the wrong forum/section, I apologize. Okay so here is my dilemma. I have written a BASH script that automatically restarts a tomcat on a given server. That part was simple enough. However, now I would like to not only restart... (14 Replies)
Discussion started by: UNM_Lobo
14 Replies

9. Shell Programming and Scripting

When i am trying to execute export command within a shell script it is saying command not found.

I am running the export command within a view to use that value inside my build script. But while executing it it is saying "export command not found" My code is as follows: -------------------------- #!/bin/sh user="test" DIR="/bldtmp/"$user VIEW="test.view1" echo "TMPDIR before export... (4 Replies)
Discussion started by: dchoudhury
4 Replies

10. UNIX for Dummies Questions & Answers

Stumped .. is this a command line arg?

I need a bit of explanation: LogFile=${LOGS_DIR}/${1}_$$ I know: - LOGS_DIR is an environment variable - $$ is the PID ... but what is ${1} ?? Is it another method to access a command line variable, or the job name? Thanks! Jon (3 Replies)
Discussion started by: jdorn001
3 Replies
SSH-ARGV0(1)						    BSD General Commands Manual 					      SSH-ARGV0(1)

NAME
ssh-argv0 -- replaces the old ssh command-name as hostname handling SYNOPSIS
hostname | user@hostname [-l login_name] [command] hostname | user@hostname [-afgknqstvxACNTX1246] [-b bind_address] [-c cipher_spec] [-e escape_char] [-i identity_file] [-l login_name] [-m mac_spec] [-o option] [-p port] [-F configfile] [-L port:host:hostport] [-R port:host:hostport] [-D port] [command] DESCRIPTION
ssh-argv0 replaces the old ssh command-name as hostname handling. If you link to this script with a hostname then executing the link is equivalent to having executed ssh with that hostname as an argument. All other arguments are passed to ssh and will be processed normally. OPTIONS
See ssh(1). FILES
See ssh(1). AUTHORS
OpenSSH is a derivative of the original and free ssh 1.2.12 release by Tatu Ylonen. Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo de Raadt and Dug Song removed many bugs, re-added newer features and created OpenSSH. Markus Friedl contributed the support for SSH protocol versions 1.5 and 2.0. Jonathan Amery wrote this ssh-argv0 script and the associated documentation. SEE ALSO
ssh(1) Debian Project September 7, 2001 Debian Project
All times are GMT -4. The time now is 03:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy