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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cant Execute Script

Status
Not open for further replies.

100mbs

MIS
Feb 14, 2002
142
US
I am having problems with executing this script from the command line.

Any Ideas as to what i am doing wrong? I want to set this script to be launched in Crontab also.

Here is what i type to execute.

su - user -c "/usr/local/bin/script.sh"

I get this error message...

ksh: /usr/local/bin/script.sh: cannot execute

Here is my script that i am trying to execute.

#!/bin/sh -xv
DATE_STRING=`date "+%Y%m%d0000"`
export DATE_STRING
#
find /logs/webserver/server1 ! -name "upload.me" ! -name "*.gz" ! -name "pid" ! -name access ! -name errors -exec gzip -f -q {} \;
find /logs/webserver/server2 ! -name "upload.me" ! -name "*.gz" ! -name "pid" ! -name access ! -name errors -exec gzip -f -q {} \;
find /logs/webserver/server3 ! -name "upload.me" ! -name "*.gz" ! -name "pid" ! -name access ! -name errors -exec gzip -f -q {} \;
find /logs/webserver/server4 ! -name "upload.me" ! -name "*.gz" ! -name "pid" ! -name access ! -name errors -exec gzip -f -q {} \;
#
find /logs/webserver/server1/uploads ! -name "upload.me" ! -name "*.gz" ! -name "pid" ! -name access ! -name errors ! -name access.tmp -exec gzip -f -q {}
\;
find /logs/webserver/server2/uploads ! -name "upload.me" ! -name "*.gz" ! -name "pid" ! -name access ! -name errors ! -name access.tmp -exec gzip -f -q {}
\;
find /logs/webserver/server3/uploads ! -name "upload.me" ! -name "*.gz" ! -name "pid" ! -name access ! -name errors ! -name access.tmp -exec gzip -f -q
{} \;
find /logs/webserver/server4/uploads ! -name "upload.me" ! -name "*.gz" ! -name "pid" ! -name access ! -name errors ! -name access.tmp -exec gzip -f
-q {} \;
 
What are the file permissions on the script?

[Blue]Blue[/Blue] [Dragon]

If I wasn't Blue, I would just be a Dragon...
 
Does su - user -c "sh -xv /usr/local/bin/script.sh" work? If so, it's probably a problem with the shebang line... is sh really in /bin or /usr/bin?

Annihilannic.
 
It was the /bin/sh in the first line. It should be /usr/bin/sh.


Thanks for your help.
 
for me the first line was false
The first line don't accept parameters
#!/bin/sh -xv
i tried
#!/bin/sh
set -xv

or the permission of the script is bad because the error is
cannot execute
r+x minimum for the user executing this script


test the script without execution with the id of user
/bin/sh -n
 
biblio93, you can usually add parameters to the shebang line; I regularly add -x to it when debugging scripts.

I seem to recall being told once that some Unix flavours will only accept a limited number of characters on the shebang line (32 or so?) so you can't specify many options, but that is probably obsolete information now...

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top