Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dirname not working in 'at' spawned script

Status
Not open for further replies.

rdp010

Technical User
May 12, 2003
1
US
I have a script which shells itself. Within the script is
a command ADWENV="${ADWENV:-$(dirname $0)/adwenv}". This command works okay if the script is submitted via cron, but during the execution of the script from the 'at' scheduler it abends. UX:sh: ERROR: /ADW/dev01/bin/rdp-shellself1.sh: $(dirname: not found
 
Anything run by [tt]cron[/tt] or [tt]at[/tt] runs in a bourne shell ([tt]/bin/sh[/tt]). It also doesn't run your [tt].profile[/tt], so environment variables you are expecting to be there might not be.

You need to make sure you have a...
[tt]
#!/bin/ksh
[/tt]
...as the first line of your script. Also, you can either add a...
[tt]
. ~/.profile
[/tt]
...as your next line. You can also change that line to look like...
[tt]
ADWENV="${ADWENV:-$(/usr/bin/dirname $0)/adwenv}"
[/tt]
There are other things you can do, but this should get you started.

Hope this helps.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top