Operating System - HP-UX
1834307 Members
2249 Online
110066 Solutions
New Discussion

Re: Need Shell Script Help

 
Ashok_20
Occasional Contributor

Need Shell Script Help

Hi,

I need some Shell Script Help. I want to have a shell script on one m/c, whose contents will be as follows:

# -- M/c1 scripts
.//test.env
.//test1.sh
rlogin M/c2
.//test1.env
./PATH_NAME>/test1.sh
exit
-- Comback to M/c1 and execute some more scripts
When I am trying to execute a test scripts, It comes till rlogin m/c2. But stays at the prompt. does not proceed to the next setup commands.

Am I missing something?

Please help me in writing a shell script and finding some good site about learning Shell Scripts.
14 REPLIES 14
Alex Lavrov.
Honored Contributor

Re: Need Shell Script Help

What do you want rlogin to do? Do you want to execute test1.env and test1.sh on the remote host? If so it's not the way to do it. rlogin just waits for input from stdin, it's interactive program.

I believe you need remsh or if you have ssh use ssh.

If I understood you right, on the remote box you must create .rhosts file in the user home directory and write there the ip and the user that can execute the commands, then you can use remsh without getting adked about password.

For example, you have two hosts:
111.111.111.111
111.111.111.222

you want user alex to execute scripts on the remote box with user danny.
Login into remote box and in the home directory of danny create file .rhosts and put in it:
111.111.111.111 alex

Now on 111.111.111.111 you can do:
remsh -l danny 111.111.111.222 "ls -l /tmp"

(usage: remsh -l )

For more details you can man remsh.
But I suggest to use ssh. Easier and secure.
I don't give a damn for a man that can only spell a word one way. (M. Twain)
Jannik
Honored Contributor

Re: Need Shell Script Help

3 host sollution with ssh!
Install keys for ssh on node 2 and 3 the client servers :-)

host1 (master script host):
#!/usr/bin/ksh
scp .//test.env user@host2:.//
scp .//test.env user@host3:.//
ssh user@host2 -c ".//test.env"
ssh user@host3 -c ".//test.env"
ssh user@host2 -c "rm .//test.env"
ssh user@host3 -c "rm .//test.env"

You could put the commands together with a ';' as sepperation, but for the ex. this is better.

Hope it helps!
jaton
Bill Hassell
Honored Contributor

Re: Need Shell Script Help

rlogin is the problem. It is an interactive command so the shell script can't proceed. If you need to run remote commands, use remsh or if you have ssh imstalled, it is much preferred ove remsh.


Bill Hassell, sysadmin
Ashok_20
Occasional Contributor

Re: Need Shell Script Help

Sir,

Thanks for Your Reply. I tried using the following Command and get the following error.

ssh applmgr@bdfdb2 -c '. /oracle/FAHRIS/fahrisora/8.0.6/FAHRIS_bdfdb2.env'

Error:

Unknown cipher type '. /oracle/FAHRIS/fahrisora/8.0.6/FAHRIS_bdfdb2.env'
Alex Lavrov.
Honored Contributor

Re: Need Shell Script Help

I think it has something to do with keys. Did you copy key from the server into authorized_keys file on the remote host?
I don't give a damn for a man that can only spell a word one way. (M. Twain)
Ashok_20
Occasional Contributor

Re: Need Shell Script Help

sir,

Both My hosts are HP Unix (11.11). I did nt copy authorized_keys . Can you ple guide me how to do that ?

Thanks & regards
Ashok
Alex Lavrov.
Honored Contributor

Re: Need Shell Script Help

Yep, here is an exellent guide:

http://www.cvrti.utah.edu/~dustman/no-more-pw-ssh/

I can't explain it better :)
I don't give a damn for a man that can only spell a word one way. (M. Twain)
Olivier LEGRAND
Frequent Advisor

Re: Need Shell Script Help

Hi,

I need some Shell Script Help. I want to have a shell script on one m/c, whose contents will be as follows:

# -- M/c1 scripts
.//test.env
.//test1.sh
remsh M/c2 ".//test1.env;./PATH_NAME>/test1.sh"
Steve Steel
Honored Contributor

Re: Need Shell Script Help

Hi


www.shelldorado.com

read and learn


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Alex Lavrov.
Honored Contributor

Re: Need Shell Script Help

What's the question? :)
I don't give a damn for a man that can only spell a word one way. (M. Twain)
Ashok_20
Occasional Contributor

Re: Need Shell Script Help

Thanks Olivier,

Its working Now. I used remsh and able to run the script. Thansk for your help.

Thanks To Alex Also for his cooperation.

regds

Ashok
Olivier LEGRAND
Frequent Advisor

Re: Need Shell Script Help

It is a great pleasure for me.

Can you assign few points, for all of us.

Thanks

Olivier
Ashok_20
Occasional Contributor

Re: Need Shell Script Help

Hi Oliver,

I will be glad to assign Points. But where and how to assign points ?
Alex Lavrov.
Honored Contributor

Re: Need Shell Script Help

At the right corner of each message box you can see a dropdown. Currently it says "unassigned", but you can change it to the number of points, according to how this answer helped you (if it helped) and then click "Submit".

That's all :)
I don't give a damn for a man that can only spell a word one way. (M. Twain)