Path Error in script

Hi All,

I copied an existing script so that I could make updates to it and test those updates.

In both scripts I set the path which is the exact same in both scripts as I copied from the old to the new script.

setting path is this command:

# Add the path required for EMC commands to run correctly
export PATH=$PATH://usr/bin:/etc:/usr/sbin:/usr/local/bin:/usr/symcli/bin:/usr/emc/scripts:/usr/sbin

In the old script there is absolutely no problem with this path setting whether you run it manually or via the crontab.

In the old script when it runs the path settings I get the following output:

$ sudo ./DAILYCHECKS.VMAX.sh.old.08022012
+ export PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:/home/isoscwi/bin:/usr/bin/X11:/sbin:.:/usr/local/bin:/usr/symcli/bin:/usr/emc/scripts:/usr/sbin://usr/bin:/etc:/usr/sbin:/usr/local/bin:/usr/symcli/bin:/usr/emc/scripts:/usr/sbin

In the NEW script when it runs the path settings I get the following output:

$ sudo ./DAILYCHECKS.VMAX.sh
./DAILYCHECKS.VMAX.sh: ukaixtsm001:/home/isoscwi/CAPACITY: not found
+ export PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:/home/isoscwi/bin:/usr/bin/X11:/sbin:.:/usr/local/bin:/usr/symcli/bin:/usr/emc/scripts:/usr/sbin://usr/bin:/etc:/usr/sbin:/usr/local/bin:/usr/symcli/bin:/usr/emc/scripts:/usr/sbin
./DAILYCHECKS.VMAX.sh: PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:/home/isoscwi/bin:/usr/bin/X11:/sbin:.:/usr/local/bin:/usr/symcli/bin:/usr/emc/scripts:/usr/sbin://usr/bin:/etc:/usr/sbin:/usr/local/bin:/usr/symcli/bin:/usr/emc/scripts:/usr/sbin: is not an identifier

I am a bit confused as to what is going on here, like I said this bit has remained untouched and it is being run from exactly the same place as the old one.

One other thing to add, when I am testing, I have # the export command out while using the sudo ./<script> and it works. I added it into the crontab last night and it ran through but was unable to run any of the commands, which I assume at the moment is because it did not have the PATH set.

Any suggestions on what I might be missing here?

Col

What shell are you using? Are you setting it explicitly in the shebang of your script? If not perhaps the default shell differs or the /bin/sh of the two systems are not equal?
In old shells you had to assign the variable first and then export:

PATH=/blabla:/blabl/gr
export PATH

Are you on Solaris maybe? /bin/sh there is pretty old. Alternatively use /usr/xpg4/bin/sh

BTW: better not put a dot in your PATH..

1 Like

Check whether the shell is same.
one thing you can try is instead of "export" try with "set"

---------- Post updated at 03:44 AM ---------- Previous update was at 03:44 AM ----------

Check whether the shell is same.
one thing you can try is instead of "export" try with "set"/"setenv" if it is csh

1 Like

The first error looks like a piece of bad code, possibly as a result of editing with a Microsoft editor such as Notepad. We'd need to see the script with bad characters made visible:

sed -n l DAILYCHECKS.VMAX.sh

The second error "is not an identifier" comes from an original Bourne Shell. The "export" command was not available in that Shell.
As Scrutinzer implies, you probably need a shebang line at the top of the script to invoke the correct Shell.

If the two scripts are similar, try looking at the differences:

diff DAILYCHECKS.VMAX.sh DAILYCHECKS.VMAX.sh.old.08022012
1 Like