Hi, I posted this in the Solaris forum but I think this one would be more appropriate.
I created a script starting with the following lines:
#!/usr/bin/ksh
flag=n
export flag
typeset -i quant=0
(...)
When running it I'm getting the following 2 errors:
/tmp/tstscript/testfail.ksh: typeset: not found
/tmp/tstscript/testfail.ksh: function: not found
crontab uses /bin/sh (Bourne shell in Solaris, if I'm not mistaken), it looks like it's not recognising the shebang (first line of the scripts, with no blank lines before).
Yes, the error output is what I pasted in the previous message:
/tmp/tstscript/testfail.ksh: typeset: not found
/tmp/tstscript/testfail.ksh: function: not found
/tmp/tstscript/testfail.ksh: syntax error at line 29: `}' unexpected
Bourne shell doesn't recognise typeset, that's why I thought that maybe it's not using the korn shell. Other than that I don't know what could be wrong.
I've tried both (didn't know about the second one, thanks) and it still gives the same error. I also think it's a problem with Solaris, but I'm not sure anymore. It's frustrating, I can't seem to find any info in google.
Many years ago I found a way to force the shell for a cron job. It's probably not the best way to do it and it may be as bakunin has suggested. What I coded within cron (and it was running some 15 years before we moved platform ) was something like this mess:
00 07 * * * /usr/bin/ksh %/usr/bin/my_ksh_script
I can't remember how I worked this out or why I thought it was a good idea, but it seemed to work. The % marker did something special and it worked, but the machine it was on is now gone by 2 years, so I can't be sure. I remember thinking that /usr/bin was a great place to put my code, seeing as it was in everyone's path. I think I'd recommend against that now!
I must say that what you have all looks to be in order. Perhaps a quick test script could be knocked together along the lines of:
#!/bin/ksh
ps -f>/tmp/ps-f
ps -l>/tmp/ps-l
Have a look at the processes listed to see if that gives you more hints.
This has to be so because crontab jobs are started from init, which has no environment. For "ps" to be found it would have to be in the path and $PATH would be empty at this point of execution. If you want to have the same environment as your login shell in your cron job do something similar to the following:
Thanks! I'm not getting the typeset and function errors anymore!
I'm getting an error regarding another variable, but that's another story, it loks like this one is solved, I hope I can use this thread if I can't solve the variable thing.