1828246 Members
2597 Online
109975 Solutions
New Discussion

script problem

 
Mark Cater_2
Advisor

script problem

I have the following script:
#!/bin/ksh
while read UNIX_Q NT_server NT_Q
do
for hostbox in $(cat /.netrc|grep root |awk '{print $2}')
do echo $hostbox
rexec $hostbox "usr/cbin/lpshut"
rexec $hostbox "/usr/sbin/lpadmin -p$UNIX_Q -v/dev/null -mrmodel -orm$NT_server -o
rp$NT_Q -ocmrcmodel -osmrsmodel -ob3"
rexec $hostbox "/usr/sbin/lpsched"
rexec $hostbox "/usr/bin/enable $UNIX_Q"
rexec $hostbox "/usr/sbin/accept $UNIX_Q"
done
done < printers.txt

It only runs once. If i comment out the rexec and add some echo's it works ok. The rexec is the problem.
Does anyone have any ideas how to resolve this?
11 REPLIES 11
Bharat Katkar
Honored Contributor

Re: script problem

Hi,
Check the follwoing entry in inetd.conf. If it is commented then uncomment it and rerun the inetd daemon.

exec stream tcp6 nowait root /usr/lbin/rexecd rexecd

Use "# /usr/sbin/inetd -c" to make inetd daemon reread the configuration file.

Hope that helps.
Regards,
You need to know a lot to actually know how little you know
Mark Cater_2
Advisor

Re: script problem

thanks for reply but its already uncommented.
Bharat Katkar
Honored Contributor

Re: script problem

HI,
Did u configured .rhosts or /etc/hosts.equiv file properly.
See Man .rhosts and hosts.equiv.
Regards,


You need to know a lot to actually know how little you know
RAC_1
Honored Contributor

Re: script problem

rexec does not use .rhosts or /etc/hosts.equiv files. It uses .netrc file in user's home directory.

man netrc for details. set it up and it should work. Also use you rexec as follows for clarity and ease of management.

rexec "host" -l "user_name" -n "command" Also your second rexec will not work, because, there is no way on lpadmin on remote host to know what is UNIX_Q. What you will have to do is somehow put details about UNIX_Q into a file on remote hots and use it from there.

Anil
There is no substitute to HARDWORK
Bharat Katkar
Honored Contributor

Re: script problem

sorry mark..
RAC is right, rexec uses .netrc for user authentication and remsh uses rhosts or host.equiv file....
You need to know a lot to actually know how little you know
Mark Cater_2
Advisor

Re: script problem

thansk for replies. I might have made an error with copy and paste.
The script works - lp, etc all works. the problem is that rexec will only run the for loop once.
comment the rexec and it all works fine.
So rexec must send an exit signal for the for loop???
Bharat Katkar
Honored Contributor

Re: script problem

I think using remsh instead of rexec will solve your problem.
Regards,
You need to know a lot to actually know how little you know
Dennis Handly
Acclaimed Contributor

Re: script problem (rexec/remsh in loop)

>the problem is that rexec will only run the for loop once.

 

As mentioned in the fine print of RAC's reply, you need to use -n, otherwise rexec/remsh/ssh, will eat up the stdin that is driving the for-loop or while loop.

Bill Hassell
Honored Contributor

Re: script problem

You need to trace the script's actions since you didn't supply any messages that come from the script. After the the first line, add the line:

 

set -x

 

Now each step of the script will be shown and you can see what each step is doing.



Bill Hassell, sysadmin
Riccardo_Marini
Regular Visitor

Re: script problem

Your problem seems an "exit" gived by "rexec" directly on the ksh process

 

You should try to replace every line of rexec with this:

rc=`rexec    etc etc.. `

 

In this way "rexec" will be executed by another process

 

Best Regards

Dennis Handly
Acclaimed Contributor

Re: script problem (rexec/remsh in loop)

>You need to trace the script's actions since you didn't supply any messages that come from the script. ...

>Your problem seems an "exit" given by "rexec" directly on the ksh process ...

 

You guys didn't believe me when I said the problem was with missing -n? ;-)

That's the whole reason I replied to this old thread, nobody explicitly mention why -n would fix it.