Operating System - HP-UX
1845885 Members
4225 Online
110250 Solutions
New Discussion

Re: Need help in scripting

 
SOLVED
Go to solution
PVR
Valued Contributor

Need help in scripting

Hi !

I want to append the cronfile of node2 from node1 as below;

rsh node1 cat /usr/local/bin/ssh-cron-new >> node2:/var/spool/cron/crontabs/root

I know that this won't work.

Can you help me by suggesting a solution ?

Don't give up. Try till success...
8 REPLIES 8
Alan Meyer_4
Respected Contributor

Re: Need help in scripting

Assuming that rsh is configured,

from node2 enter;

rsh node1 'cat /usr/local/bin/ssh-cron-new' >> /var/spool/cron/crontabs/root
" I may not be certified, but I am certifiable... "
Pete Randall
Outstanding Contributor

Re: Need help in scripting

I would start by capturing node2's crontab:

crontab -l > /root/crontab

Then add on node1's crontab

remsh node1 cat /usr/local/bin/ssh-cron-new >> /root/crontab

At least I think that's what you're trying to accomplish.


Pete

Pete
TwoProc
Honored Contributor
Solution

Re: Need help in scripting

rsh node1 "cat /usr/local/bin/ssh-cron-new" | rsh node2 "cat >> /var/spool/cron/crontabs/root"
We are the people our parents warned us about --Jimmy Buffett
PVR
Valued Contributor

Re: Need help in scripting

Sorry !

I forgot to mention that rsh is configured.

I have to run this script only from node1 and rsh is configured (w/o password) only from node1 to node2.

From node2 to node1 it is not configured. I have around 150 boxes where I need to update the cron file.
Don't give up. Try till success...
Alan Meyer_4
Respected Contributor

Re: Need help in scripting

given that then

I've never pushed out a file with rsh like John did, but this should also work.

rcp -rp node2:/var/spool/cron/crontabs/root /tmp/root.cron
cat /usr/local/bin/ssh-cron-new >> /tmp/root.cron
rcp -rp /tmp/root.cron node2:/var/spool/cron/crontabs/root
" I may not be certified, but I am certifiable... "
TwoProc
Honored Contributor

Re: Need help in scripting

OK since you're running from node 1, then

cat /usr/local/bin/ssh-cron-new | rsh node2 " cat >> /var/spool/cron/crontabs/root"

But, since you've got rsh, you've probably also got rcp that you can use:

scp /usr/local/bion/ssh-cron-new node2:/var/spool/cron/crontabs/root
We are the people our parents warned us about --Jimmy Buffett
Alan Meyer_4
Respected Contributor

Re: Need help in scripting

you can also put all the nodenames in a data file then loop them

cat nodes.dat |while read NODE ;do
rcp -rp $NODE:/var/spool/cron/crontabs/root /tmp/root.cron
cat /usr/local/bin/ssh-cron-new >> /tmp/root.cron
rcp -rp /tmp/root.cron $NODE:/var/spool/cron/crontabs/root
done
" I may not be certified, but I am certifiable... "
PVR
Valued Contributor

Re: Need help in scripting

Thanks to all for your immediate response !

Solution suggested by John helped me...
Don't give up. Try till success...