Automated a script that will login to another unix box and run a shell script on that box...

I'm trying to create a shell script that I could run using KRON or manually that would do the following:

1.  telnet to another unix box (Sun OS 5.6).  The originating Unix box is HP UX 12.0 64bit.
2.  While logged on to the 2nd box, run a shell script in a specified directory.  This script is already in place and runs on demand.
3.  Logout of second box.

What do I need to setup on the source and target boxes to make this work?

Thanks!
bmickeyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

manav_mathurCommented:
It would be better if instead of using telnet, you'd prefer using rsh/ssh.

Manav
0
bmickeyAuthor Commented:
I don't care what I'm using , my main goal is to be able to automated a script on another server from the first server.
0
manav_mathurCommented:
In that case, you will have to use the $HOME/.rhosts and /etc/rhosts.equiv files.
$HOME/.rhosts will contain entries for which user can be trusted.

If a user/group is trusted for a particular rhosts file, then the user can login without supplying an id/password

see this for further

http://publib16.boulder.ibm.com/pseries/en_US/files/aixfiles/rhosts.htm

after that, you may use .telnetrc if it serves your purpose.....

Manav

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

TintinCommented:
Please use ssh, then it is as simple as setting up ssh keys then doing:

ssh remotehost /script/to/run
0
chris_calabreseCommented:
Also... HP-UX 12.0?

The latest version is 11.22, with 11.23 expected in the next couple of months and 11.30 some time next year.
0
wesly_chenCommented:
Hi,

  For ssh login without password, you need
1. Login as userA on machineA and run the following commands:
   $ssh-keygen -t dsa
   $ssh-keygen -t rsa
Note : Accept the default

The above would generate 4 files under $HOME/.ssh
id_dsa
id_dsa.pub
id_rsa
id_rsa.pub

cd $HOME/.ssh
cat id_dsa.pub > authorized_keys
cat id_rsa.pub >> authorized_keys
rm id_dsa.pub id_rsa.pub
chmod 700 authorized_keys

2. Now copy this authorized_keys (which you created as above) to the home dir of the destination machine.
 In your case machineB and userA (since the user name is same on both nodes).

3. For all machines,
check sshd_config (/etc/ssh/sshd_config) file to make sure that it contains the following entry
---
PubkeyAuthentications yes

chech ssh_config (/etc/ssh/ssh_config) file for the following entry
--
ForwardAgent yes

4. Now you would be able to execute the commands on dest host without asking for password.
No matter what is the password you have for both accounts.

For example:
$ ssh <remote hostname> <command>

Regards,

Wesly
0
yuzhCommented:
If you don't worry about security, you can use rsh (setup .rhosts file etc) use:
   rsh remote-host /path-to/script

Better to use secure ssh, setup ssh login without password (otherwise use expect
script to handle the password), and use

ssh login@remote-host "/path-to/script"
0
avizitCommented:
for similar automated purpose I use expect scripts http://expect.nist.gov/
one downside is that , I need to have my password in clear text inside the script , ofcourse you can make the script readable only by you
0
pravinsalunkeCommented:
I have 2 basic doubts
1. I am trying to read command line (input typed by user) and then check the same. Pl see the script below
.....................................................................................
echo "To run application press 1"
read input
if [ "$input"=1 ]; then
echo "Pressed 1"
elif [ "$input" =2 ]; then
.....................................................................................
When I run the script gives follwing errors-
': not a valid identifieread: `input
./file.sh: line 9: syntax error near unexpected token `elif'
'/file.sh: line 9: `elif [ "$input" =2 ]; then

2. I am writting a shell script-
If I put the first statement  in shell script file as  
#!/bin/sh
When I run the script I get "file not found" error

Please clarify the same
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.