Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Search Forums:



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-07-2012
Registered User
 

Join Date: Aug 2010
Location: Bangalore India
Posts: 20
Thanks: 1
Thanked 0 Times in 0 Posts
Exclamation Login to multiple host without using Expect

Hello ,

I have a problem which involves a set of command should be executed on remote host and output should be stored in a file. But due to security reason I can not use expect to enter the password and its not possible to create password less login for multiple user to do the same thing and we can not set one user to do this task.

I have to write only shell script to do this . Perl/Python is not suggested in my environment.

However perl/python can be taken under consideration if it doesn't involves us to install any extra module. Perl/Python script should not require any extra module which needs to be installed or does not comes with the default installation.

Let me know if any one have any idea about it.

Sponsored Links
    #2  
Old 02-07-2012
ahamed101's Avatar
root is god!!!
 

Join Date: Sep 2008
Location: India
Posts: 1,478
Thanks: 33
Thanked 382 Times in 377 Posts
So, you intend to type in the password every time for each server?

--ahamed
Sponsored Links
    #3  
Old 02-07-2012
Registered User
 

Join Date: Aug 2010
Location: Bangalore India
Posts: 20
Thanks: 1
Thanked 0 Times in 0 Posts
Yeah as of now it seems to be that only. But is there any way that can be achieved? Is there any way to write my own expect function?

If that is possible I can do it . But I am not that smart in scripting yet.

Thank you
    #4  
Old 02-07-2012
ahamed101's Avatar
root is god!!!
 

Join Date: Sep 2008
Location: India
Posts: 1,478
Thanks: 33
Thanked 382 Times in 377 Posts
This can give you a start...

Code:
#!/bin/bash
user="admin"
hostlist="127.0.0.1 127.0.0.2 127.0.0.3"
for host in $hostlist
do
        echo $user@$host >> /tmp/log
        ssh $user@$host "ps" >> /tmp/log
done

The output is stored in the /tmp/log file. It will ask for password and you need to enter it!

--ahamed
Sponsored Links
    #5  
Old 02-08-2012
Registered User
 

Join Date: Aug 2010
Location: Bangalore India
Posts: 20
Thanks: 1
Thanked 0 Times in 0 Posts
Thanks but , is there a way to write a function which should act like expect or Net::SSH.

Sponsored Links
    #6  
Old 02-08-2012
ahamed101's Avatar
root is god!!!
 

Join Date: Sep 2008
Location: India
Posts: 1,478
Thanks: 33
Thanked 382 Times in 377 Posts
What do you mean by "act"?? Please elaborate.

--ahamed
Sponsored Links
    #7  
Old 02-08-2012
Registered User
 

Join Date: Feb 2012
Location: India
Posts: 102
Thanks: 9
Thanked 2 Times in 2 Posts
Without expect you can try with as below ... But this is working on Solaris serves only ...

Code:
# echo -e "ur-psw" | rsh <seever-ip" 


-- Shirish Shukla

Last edited by Franklin52; 02-08-2012 at 06:16 AM.. Reason: Please use code tags for code and data samples, thank you
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Plz help me using expect script for remote host wormym Shell Programming and Scripting 2 09-16-2011 12:13 AM
Expect get host ip rpowell86 Shell Programming and Scripting 2 06-29-2011 01:34 AM
how to handle multiple apps on host? bongo UNIX for Dummies Questions & Answers 0 09-28-2010 01:47 PM
rsh login to host with password topy Shell Programming and Scripting 11 05-03-2010 02:31 AM
change password for multiple host chang-lee Shell Programming and Scripting 3 11-06-2009 09:29 AM



All times are GMT -4. The time now is 04:37 AM.