Shellscript to Sudo other account


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shellscript to Sudo other account
# 1  
Old 11-22-2007
Shellscript to Sudo other account

Hi,

I have to write a shell script to sudo other account. Foreg,
i am working in account ramdev1, i have a sudo access where through shell script i need to sudo another account
ramdev2 and read a file "ram.inc" get those data and save it in a .txt file and return it?

Since i am new to shell script. please do provide a soln. to this. This is really urgent. Expecting positive response.

Thanx,
Sachin
# 2  
Old 11-22-2007
Search 'sudo' against the forum.
# 3  
Old 11-26-2007
cameron,

I have used "su" to sudo an account ramdev2, now i need to read a file "ram.inc" in a folder /ramenv ,parse it and get only the port no. in it and store it in a .txt file and return it. Since i am pretty much new in reading the file and storing it in a .txt pls. do provide me with an example. Expecting postive response..

Thanx,
Sachin
# 4  
Old 11-26-2007
If you used 'su' then you did not sudo. Anyway... for parsing a file, suggest you read through 12 ways to parse a file. That should be a good start. Then regarding storing a variable in a file, go through the man page of any shell (sh/bash/ksh) and search for redirection. That will help too.
# 5  
Old 11-26-2007
Quote:
Originally Posted by sachin.tendulka
cameron,

I have used "su" to sudo an account ramdev2, now i need to read a file "ram.inc" in a folder /ramenv ,parse it and get only the port no. in it and store it in a .txt file and return it. Since i am pretty much new in reading the file and storing it in a .txt pls. do provide me with an example. Expecting postive response..

Thanx,
Sachin
hey,

su is used to switch user account.
For ex:
By default you logged in into default user, but whn you want to switch the user (say your account ) then you can use "su" command,

su - xyz
password: *******

Smilie
# 6  
Old 11-26-2007
Would be interested in seeing your script.
Expecting postive response..

Cheers,
Cameron
# 7  
Old 11-26-2007
blowtorch,

Thank u for the response..I am a Java/J2EE guy. Where i have been a given a shell script to write. Since i am new to this and since you are the moderator can you help me with an example shellscript to sudo other account and
read a file "ram.inc" and get only the port no. in it and store it in ram.txt file and return it. Since this is urgent to be delivered can provide me with an example atleast.
So that i can modify it according to my need.

Thanks,
Sachin
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

What happens to your skype account if you close outlook.com email account?

Hello, Does anyone know what happens to your skype account if you close the outlook.com email account which are linked together? As you know they are both owned by Microsoft. Thanks (0 Replies)
Discussion started by: milhan
0 Replies

2. How to Post in the The UNIX and Linux Forums

Simultaneously try to execute commands after connecting to remote account to one account

I have made password less connection to my remote account. and i tried to execute commands at a time. but i am unable to execute the commands. ssh $ACCOUNT_DETAILS@$HOST_DETAILS cd ~/JEE/*/logs/ (1 Reply)
Discussion started by: kishored005
1 Replies

3. Shell Programming and Scripting

Shellscript not executing further after sudo over a user

Hi, I am writing a switch case statement and one of the option contains sudo to a particular user and then perform some steps after that but my script is unable to proceed with further execution after doing sudo over the user. Could you please suggest an workaround for this. (1 Reply)
Discussion started by: adityam
1 Replies

4. 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

5. 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

6. Linux

Apply disk quota to account(dedicate 3 GB to account).

Hi , I am faceing lot of problem due to "disk space is not enough". senerio is like as, In system has 5 account. a,b,c,d,e say account c if very critical. Due to other user's data, user 'c' is faceing disk space issue. I want to dedicate 3 GB for user 'c'. No user... (1 Reply)
Discussion started by: ashokd009
1 Replies

7. UNIX for Dummies Questions & Answers

Change Account to not lock account if password expires

I have access to 15+ UNIX boxes at work, and I do not consistently log onto all of them over time. When I do try to access one I havent been on in awhile, my account is locked as the password has expired. I need to request to the UNIX SA's that the password expiration is 90 days and that if it... (1 Reply)
Discussion started by: stringzz
1 Replies

8. UNIX for Dummies Questions & Answers

Setting an account to be a non-login account automatically?

Is there a way to easily change an account to be a non login account (NP in the shadow) file? I know I can just edit the file but that is not what we want to do. We use access control software and want to provide a way to set an account to be non-login using simple commands that can be mapped... (0 Replies)
Discussion started by: LordJezo
0 Replies

9. UNIX for Dummies Questions & Answers

Account creation Sudo enabled

Hi, how to create account with the following be cron enabled only accessible via sudo (1 Reply)
Discussion started by: vilves
1 Replies
Login or Register to Ask a Question