Command not found in shell script - stumped for 4 days
Hello,
I like to begin with .. 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.....
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
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...
1) Maybe you have reached the maximum number of open files on your system and need a kernel rebuild.
Particularly vulnerable if you job is running at the same time as something large like a backup.
2) Maybe backup software is locking the file. (long shot)
3) I prefer pludi's idea. Automounter involved?
---------- Post updated at 16:26 ---------- Previous update was at 16:19 ----------
Also check the script file itself for funny characters.
Can it be that you are using application servers and that SAP sometimes runs the script on one server and sometimes on another?
Hello Scrutinizer, Thanks. We have 3 SAP Application servers. The script is on only 1 of them. In my environment, the script is kicked up every time. However, it errors out and terminates 50% of the time so this should rule out the possibility that SAP called the script on other App servers. I appreciate your help. J Phang
---------- Post updated at 03:10 AM ---------- Previous update was at 02:41 AM ----------
Quote:
Originally Posted by methyl
1) Maybe you have reached the maximum number of open files on your system and need a kernel rebuild.
Particularly vulnerable if you job is running at the same time as something large like a backup.
2) Maybe backup software is locking the file. (long shot)
3) I prefer pludi's idea. Automounter involved?
---------- Post updated at 16:26 ---------- Previous update was at 16:19 ----------
Also check the script file itself for funny characters.
Hi methyl, Thank you. I did a check on the points you had brought up.
1) That's a possibility. I'll need to investigate the number of open files in the day. It sounds logical because the script worked early in the morning before lots of people started arriving for work, it worked occasionally during the day and then almost 100% after 5 pm in the afternoon when most people got off.
2) Our backup software runs against a cloned copy of the disks via symclone. Plus the error which says that the ssh binary isn't found instead of other errors. Less likely this could be it.
3) I've checked again and can confirm that /bin is directly under root and not mounted. Autofs is inactive. Also, if I run this script over a SSH session, it'll work 100%.
4) I've ran an equivalent command over previously "cat -vet" to check for quite the same thing. The command ran when I kicked it off interactively so it shouldn't be a character issue.
Thanks for the suggestions. At least I know what else to check for tomorrow. Being in Asia means it's 3.10am now. My apologies if I couldn't reply more quickly.
J Phang
This error can happen if a script is executed with a #! line that references a non-existent shell. Like this:
./fubar is there. It's /no/such/file that is missing. Very misleading error message though.
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)
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)
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)
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)
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)
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)
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)
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)
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)