Operating System - HP-UX
1826102 Members
4790 Online
109690 Solutions
New Discussion

shell/tcp: Unknown Service error in script...

 
Timothy Polus
New Member

shell/tcp: Unknown Service error in script...

I've got a script running out of cron which in essence does the following:

remsh to host, run command.
remsh to different hosts, run different command

When run on the command line this works fine. When each command is run seperately in cron it works fine. When run together under cron the first remsh succeeds, the second returns 1 and the error: "shell/tcp: Unknown Service"

In checking around, the only info I see on Unknown Service errors has to do with the /etc/services file (logically enough,) unfortunately the services file on both machines are fine, as is the one on the executing host. Anyone run into something similar?

-Timothy
8 REPLIES 8
Tim D Fulford
Honored Contributor

Re: shell/tcp: Unknown Service error in script...

Timothy

When you run the commands together how do you do it? ie
remsh machinea ;remsh machineb
or
remsh machinea
remsh machineb

I also suggest you put some logging in the script & cron i.e in cron
? ? ? ? ? path_to_script >> /tmp/logfile 2>&1
in the script
put after each command
echo "cmd: ?? $?" >> /tmp/logfile

This may help

Good luck

Tim
-
Sachin Patel
Honored Contributor

Re: shell/tcp: Unknown Service error in script...

Hi Timothy,
script which is going to run from cron requires a full path i.e
/usr/bin/remsh client1 /usr/bin/date
/usr/bin/remsh client2 /usr/sbin/swlist

Sachin
Is photography a hobby or another way to spend $
someone_4
Honored Contributor

Re: shell/tcp: Unknown Service error in script...

Hey Tim ,
Check out the paths in your script with the command. Here is a post that will help you out:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,1150,0x026746ff9277d511abcd0090277a778c,00.html
If this doesnt work. Post your script I am sure someone will get you going ..

Richard
Timothy Polus
New Member

Re: shell/tcp: Unknown Service error in script...

I have added some error checking, $? returns a 1 for remsh, with the above error. While the remsh itself doesn't have the full path, it doesn't appear to be an issue with it not finding remsh, since I'm getting the above error it tells me I'm at least _trying_ to remsh to the box from the script, but for whatever reason it's not successful. Also, the first remsh is working fine, and it's no more fully qualified than the next one. Here's a snippet from the code:

# Run edge reports

remsh landmine ". /exe/users/env/tibadmin.profile; . /exe/users/env/staff.profile; ${PL_DIR}/ClearingEdge.pl $PROGARGS 2>&1 > /tmp/edge_report.log"

mail blah@blah.com < /xcb/apps/ctl/edge.msg

###########################
#### Run entire P&L ######
###########################

remsh p-apsrv1 ". /exe/users/env/tibadmin.profile; . /exe/users/env/staff.profile; ${PL_DIR}/plrun.pl -D -U -P -S $PROGARGS -C 2>&1 > /tmp/runpl_cron_am.log1"



The first remsh is working fine, the second is returning 1 and giving the Unknown Service error.

-Timothy
A. Clay Stephenson
Acclaimed Contributor

Re: shell/tcp: Unknown Service error in script...

Hi Timothy:

I have two thoughts and I'm almost certain that one of these is going to fix you. When you run under cron two things happen: 1) your environment is very sparse and 2) stdin, stdout, and stderr are nolonger a terminal.

I would add the -n arg to remsh to tell it to take stdin from /dev/null and every one of your remote commands should do a
if [ -t 0 -a -t 1 -a -t 2 ]
then
XXXXX
fi
in every place that a possible interactive command or TERM associated command (stty,tabs,...) is executed. This is especially true of your profiles.

Clay
If it ain't broke, I can fix that.
someone_4
Honored Contributor

Re: shell/tcp: Unknown Service error in script...

what if you do:
remsh host -l root command

Richard
Bob_Vance
Esteemed Contributor

Re: shell/tcp: Unknown Service error in script...

. What user id are you running as under cron?

. Also, try a simple script that just does

remsh landmine hostname
remsh p-apsrv1 hostname

. You realize that the double quotes are not protecting
${PL_DIR}
and $PROGARGS
in the script, right?
Thus, those variables are being resolved in the script and the values being passed for those variables are those extant *within* this script, *not* whatever values may be returned on the remote host via

. /exe/users/env/tibadmin.profile
and . /exe/users/env/staff.profile
.
BV
"The lyf so short, the craft so long to lerne." - Chaucer
Mladen Despic
Honored Contributor

Re: shell/tcp: Unknown Service error in script...

Hi Timothy,

Try using this syntax:

remsh landmine -n "..."
remsh p-apsrv1 -n "..."

etc.