Operating System - HP-UX
1822435 Members
2596 Online
109642 Solutions
New Discussion юеВ

/usr/bin/sh remsh budapest -l root -n "su - spmadm -c ls"

 
SOLVED
Go to solution
Carles Viaplana
Valued Contributor

/usr/bin/sh remsh budapest -l root -n "su - spmadm -c ls"

Hello,

Does anybody know why I can execute the following command from crontab?

remsh budapest -l root -n "su - spmadm -c ls"

When I try from command line all works fine, but from crontab it doesn't, so I tried to execute command using same shell crontab uses and I get this error:

# /usr/bin/sh remsh budapest -l root -n "su - spmadm -c ls"
/usr/bin/sh: remsh: Execute permission denied.
#

Any idea?

Thanks for your help.
Regards,

Carles
11 REPLIES 11
Steven E. Protter
Exalted Contributor

Re: /usr/bin/sh remsh budapest -l root -n "su - spmadm -c ls"

Shalom,

Very often things don't work in cron because cron has no environment.

Check the PATH variable among other issues.

env > /tmp/env.regular.txt

The more the environment in the cron script looks like that file the metter chance you have of your script running right.

Also to make the environment work normally, I suggest this format:
remsh otherhost scriptname

scriptname contains the environment variables and the command line you wish to run inside the script.

Unrelated for security reasons I recommend you stop using remesh and ush ssh from openssh(Secure Shell) which has the same command line functionality but encrypted authentication and datastream.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Peter Godron
Honored Contributor
Solution

Re: /usr/bin/sh remsh budapest -l root -n "su - spmadm -c ls"

Hi,
you have to either supply a search path or specify the path for the executables i.e.
/usr/bin/remsh budapest -l root -n"su - spmadm -c -ls"

Also double check permissions:
ll /usr/bin/remsh
( On my system -r-sr-xr-x 1 root bin )
Victor BERRIDGE
Honored Contributor

Re: /usr/bin/sh remsh budapest -l root -n "su - spmadm -c ls"

Hi Carles,
Who are you when you execute your script?
Do you have a .rhost? on budapest?
You may have a few env to set...

All the best
Victor
Carles Viaplana
Valued Contributor

Re: /usr/bin/sh remsh budapest -l root -n "su - spmadm -c ls"

Hi all,

I execute remsh using full path but command still fails.

Permissions are the same Peter Gordon said.

Connection to remote host work fine and I launched test as root user.

I don't think ENV is the issue as I'm just trying to launch a simple command like ls.

Finally, I can't change access method right now, so I need to fix issue.

Thanks to all for your support.
Regards,

Carles
Victor BERRIDGE
Honored Contributor

Re: /usr/bin/sh remsh budapest -l root -n "su - spmadm -c ls"

Hi Carles,

I tried, and for me it works...
It shows that if you are to use su -, you will have to add a test for interactive shell to stop "not typewriter..." messages in output.
My config for it to work is using in root homedir of the remote box a .rhosts file

Here is the line in cronfile:
52 16 * * * remsh draco -l root -n "su - vbe -c ls">/home/vbe/cron.log 2&1

Here is what I see in my local homedir:
ant:/home/vbe $ ll cro*
-rw-r--r-- 1 root sys 547 Nov 6 16:52 cron.log


All the best
Victor
Victor BERRIDGE
Honored Contributor

Re: /usr/bin/sh remsh budapest -l root -n "su - spmadm -c ls"

Hi again,

I tested with my own account just now, as an idea for you to try to debug. the idea is to read your account's mail to see what cron has put there if any error. I suggest you try also, I found it coulnt execute because the previous test I did was with root and so the output file belonged to root and I (vbe) wasnt allowed to write to...
The interesting is the message cron gave:
Received: (from root@localhost)
by ant.ge.ch (8.9.3 (PHNE_34936)/8.9.3) id RAA18829
for vbe; Mon, 6 Nov 2006 17:25:00 +0100 (MET)
Date: Mon, 6 Nov 2006 17:25:00 +0100 (MET)
From: root@ant.ge.ch
Message-Id: <200611061625.RAA18829@ant.ge.ch>
Subject: cron

sh: /home/vbe/cron.log: Cannot create the specified file.
sh: 1: not found.


*************************************************
Cron: The previous message is the standard output
and standard error of one of your crontab commands:

remsh draco -l root -n "su - vbe -c ls">/home/vbe/cron.log 2&1


What do you think? Give it a try?
You would have to put your user in the remote box root hoemdir/.rhosts etc...

But from then on we could try together and with others to comment your results

All the best
Victor
Peter Godron
Honored Contributor

Re: /usr/bin/sh remsh budapest -l root -n "su - spmadm -c ls"

Carles/Victor,
typo ?
Should
" 2&1 "
be
"2>&1 "

This should resolve your "sh: 1: not found."
error.
Victor BERRIDGE
Honored Contributor

Re: /usr/bin/sh remsh budapest -l root -n "su - spmadm -c ls"

Peter

Yes you are right I missed > when typing (to fast...)
And was more concerned by the Cannot create message and couldnt figure out the next one, not realizing it was another error...

Many thanks again!

Have you a clue about Carles issue?

All the best
Victor
OldSchool
Honored Contributor

Re: /usr/bin/sh remsh budapest -l root -n "su - spmadm -c ls"

ok,

So who are you logged in as when "it works from the command line"

and

Whose crontab is it being run from?
Carles Viaplana
Valued Contributor

Re: /usr/bin/sh remsh budapest -l root -n "su - spmadm -c ls"

Hi all,

Sorry for delay in my reply, but we're doing migrating SAP at same time and we're quite busy...

I tested command using full path and it seems to work fine right now (note I execute remsh without full path).

Now I need to verify with other remote command I should launch every night at 01h GMT+1.

In case it works tonight, remsh issue will have been fixed. Otherwise issue could be in remote system and new command to execute instead remsh command.

Anyway, I'll keep you informed.

Thanks to all for your help.
Regards,

Carles
Carles Viaplana
Valued Contributor

Re: /usr/bin/sh remsh budapest -l root -n "su - spmadm -c ls"

Ops! I forgot to close thread!

Last night crontab worked fine after specifying remsh full path.

Thanks to all for your help!
Regards,

Carles