1820530 Members
2147 Online
109626 Solutions
New Discussion юеВ

Re: Executing script

 
SOLVED
Go to solution
Igor Sovin
Super Advisor

Executing script

I have some script that should be run under special user.
But when I try to run srcipt
./scriptname.sh
command inside the script doesnt execute

what should I do to overcome that problem?



22 REPLIES 22
Arunvijai_4
Honored Contributor

Re: Executing script

Hello,

Are you using relative path or just command names inside the script ? Try to use full path instead of relative paths. Just like,

# print_manifest

Instead, use
$ /opt/ignite/bin/print_manifest

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Igor Sovin
Super Advisor

Re: Executing script

I also did that
It takes no effect
Arunvijai_4
Honored Contributor

Re: Executing script

Ok, Do the special user has permission to execute the command(s)? Does it happen for all the system related commands as well ? (ls, find, etc..etc..)?

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
saju_2
Respected Contributor

Re: Executing script

Hi

Whether the special user has execute permission for that script?

Regards
CS
Igor Sovin
Super Advisor

Re: Executing script

The script commands are simple:

echo 123qwe
ll

Both commands are executing successfully from the command line.

Script has the following permissions
-rwxr-xr-x 1 oraslv dba 35 Feb 7 17:20 11.sh

I try to run script under oraslv

Unfortunately I cant do that yet
Vibhor Kumar Agarwal
Esteemed Contributor

Re: Executing script

You can try sudo!
Vibhor Kumar Agarwal
Igor Sovin
Super Advisor

Re: Executing script

I did everything that was advised, but it didnt help
Arunvijai_4
Honored Contributor

Re: Executing script

Hello,

Which shell you execute ? Also, Can you do this,

$ ./script.sh 2>&1 out

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Igor Sovin
Super Advisor

Re: Executing script

I execute sh shell

kate:oraslv> 11.sh 2>&1 out
kate:oraslv>

no result
Igor Sovin
Super Advisor

Re: Executing script

Script listing

kate:oraslv> more 11.sh
#!/usr/bin/sh
echo 123
ls

kate:oraslv>
Igor Sovin
Super Advisor

Re: Executing script

If I delete line "#!/usr/bin/sh"
everything works normally
Arunvijai_4
Honored Contributor

Re: Executing script

Also, do a cat to out and you get anything there.

Try to assign points to people who responded you.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Arunvijai_4
Honored Contributor
Solution

Re: Executing script

Hello,

Try to use with #!/sbin/sh or #!/usr/bin/ksh.

Also, $ ./11.sh 1>out
$ cat out

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Vibhor Kumar Agarwal
Esteemed Contributor

Re: Executing script

Since removing the line #!/usr/bin/sh
helps.

That means you have written the script in a form not understood by sh.

So do you want to keep this line.
Vibhor Kumar Agarwal
Igor Sovin
Super Advisor

Re: Executing script

I used ordinary commands in my script, shell sh should understand it

Igor Sovin
Super Advisor

Re: Executing script

I used ordinary commands like 'ls' and 'echo' in my script, shell sh should understand it

Vibhor Kumar Agarwal
Esteemed Contributor

Re: Executing script

Can you post your script?
Vibhor Kumar Agarwal
Igor Sovin
Super Advisor

Re: Executing script

here it is


#!/usr/bin/sh
echo 123
ls

Muthukumar_5
Honored Contributor

Re: Executing script

Try as,

#!/usr/bin/sh
echo "123"
ls -l
#
# chmod u+x script.sh
# sh -x ./script.sh

what are you getting here?

--
Muthu
Easy to suggest when don't know about the problem!
Muthukumar_5
Honored Contributor

Re: Executing script

Can you check this?

# which sh
# ls -l /usr/bin/sh


May be /usr/bin/sh file is having a problem. Use like, /sbin/sh instead of /usr/bin/sh. It is better that we can use that script of single user environment if it is possible with script lines using /sbin/sh.

Try as,

#!/sbin/sh
echo "123"
ls

Execute now.

--
Muthu
Easy to suggest when don't know about the problem!
Igor Sovin
Super Advisor

Re: Executing script

Okay, now it works
thanx to all
Arunvijai_4
Honored Contributor

Re: Executing script

Hello,

You can close this thread.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"