Need a script for sudo, login and output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need a script for sudo, login and output
# 1  
Old 08-05-2013
Need a script for sudo, login and output

Hello All ,

Hope everyone is doing great !

can someone help me for the below problem statement with the help of a script .

1. I am having couple of Linux Servers
a. I need to login and need to do a sudo
b. need to give a user id , which will take to user directory`s homedirectory . ( say homedirectory name is radha )
c. It shall take me to a command prompt kind of GUI ( which is golden gate , if anyone aware of ) , where i need give a command "info all" then it shall list all the proccess running in that .
d. then i need to give a command for DATE , which will show the date .
e. click exit , exit
2. The o/p from server1 has to come to a notepad in local system .
3. we need to repeat the step-1 again for server 2 and output has to append to notepad created for server 1
4. same has to be done for other servers



Code:
Sample : 

ssh <server1>
password:

$pbrun bin/su - <sudouser>

$radha

radha > info all
process1 running
process2 stopped
process3 running
radha > sh date
radha > exit

Thanks in advance .

---------- Post updated at 11:55 PM ---------- Previous update was at 11:40 PM ----------

Hi All ,

If an option possible to send email to a DL , that also helps instead of copying to desktop in notepad .

Thanks.
# 2  
Old 08-07-2013
Code:
USER="radha"

for server in server1 server2
do
   echo "working on server $server
   ssh $USER@$server "sudo command;date;info all"
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Automating su ( sudo ) login

Hi, I am planning to automate a deployment process and the below are the steps Connect from windows to Unix server Login with user name : admin and password After logging in , switch user to root to get additional privileges Perform actions on files and directories post switching to... (3 Replies)
Discussion started by: venkidhadha
3 Replies

2. Shell Programming and Scripting

How to execute command remotely as sudo and save the output locally?

Hello , I am trying to run a NetBackup command in remote server. Also this command can only be run by root so I am using sudo . Also I want the output of the command locally in a file. The below command asked for password , ran successfully and showed Output on my local server screen ... (2 Replies)
Discussion started by: rahul2662
2 Replies

3. Shell Programming and Scripting

Problem connect to a different server then do sudo login and finally run some scripts and get result

I have to write a shell script in my current linux server and I have to connect to a different server then do sudo login and finally run some scripts residing in a particular directory and get results back. I am starting to write my shell script as below but after I do ssh login it prompts for... (2 Replies)
Discussion started by: Devesh5683
2 Replies

4. UNIX for Dummies Questions & Answers

Passing password to sudo login

Hi All, I am trying use the below su command to execute a shell script using different user. Caould some one please help me out as to how to pass the pass the password when prompted or is there any way to execute the shell script using other user. I have had look at the other posts in forum... (1 Reply)
Discussion started by: abhi_n123
1 Replies

5. Shell Programming and Scripting

ssh foo.com sudo command - Prompts for sudo password as visible text. Help?

I am writing a BASH script to update a webserver and then restart Apache. It looks basically like this: #!/bin/bash rsync /path/on/local/machine/ foo.com:path/on/remote/machine/ ssh foo.com sudo /etc/init.d/apache2 reloadrsync and ssh don't prompt for a password, because I have DSA encryption... (9 Replies)
Discussion started by: fluoborate
9 Replies

6. UNIX for Dummies Questions & Answers

sudo login issue

I logged in through ssh, but can't re-login as root. sudo login Arch login: root Password: Login incorrect Arch login: But I am sure my password is right. Why? But on local tty1, this works. (2 Replies)
Discussion started by: vistastar
2 Replies

7. Shell Programming and Scripting

Issue in passing passwd to login into a sudo account

Hi Gurus, I have small issue... I used to pass the passwd for sudo commands like below, gzcat ~/passwd.gz | sudo su - <villin> >> eof ------ ----- ------ eof And it was able to login into "villin" sudo account successfully. But now, I'm using the same in another script for the... (2 Replies)
Discussion started by: raghu.iv85
2 Replies

8. UNIX for Advanced & Expert Users

ssh and sudo login

Hi, I am trying to execute some command, via ssh and sudo. Here is what i want to do. ssh localhost | sudo su - ldaprole | ls -ltrh However, this command gives me listing of my home directory, and not of ldaprole. If I logic directly, when i perform sudo su - ldaprole, it... (5 Replies)
Discussion started by: john_prince
5 Replies

9. Shell Programming and Scripting

ksh script that echo " please insert your name " and store the output to a login.log file.

Hello All Nice to meet you all here in this forum, it's my 1rst time here i'm asking about a little issue that i face i added a ksh script that echo " please insert your name " and store the output to a login.log file. the script is working fine with normal telnet but Xstart is not working... (8 Replies)
Discussion started by: islam.said
8 Replies

10. Shell Programming and Scripting

HOw can i use sudo in a script

Hi Everyone, i am writing a script which will display all channels as below sudo /usr/bin/su - mycamqrd chs I kept the above two lines in a ksh and after ran that it is going to mycamqrd home dir(sudo /usr/bin/su - mycamqrd).. The script is coming out and it is not executing chs. Please... (5 Replies)
Discussion started by: rajesh212512
5 Replies
Login or Register to Ask a Question