The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Change Account to not lock account if password expires stringzz UNIX for Dummies Questions & Answers 1 04-04-2008 06:31 PM
sudo, or not sudo: that is the question iBot UNIX and Linux RSS News 1 02-07-2008 01:40 PM
Setting an account to be a non-login account automatically? LordJezo UNIX for Dummies Questions & Answers 0 06-16-2006 10:28 AM
Account creation Sudo enabled vilves UNIX for Dummies Questions & Answers 1 06-06-2006 11:35 AM
ftp in Shellscript ggowrish UNIX for Advanced & Expert Users 3 06-11-2004 09:09 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-22-2007
sachin.tendulka sachin.tendulka is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 32
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 (permalink)  
Old 11-22-2007
Cameron's Avatar
Cameron Cameron is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2001
Location: Brisbane, Australia
Posts: 500
Search 'sudo' against the forum.
  #3 (permalink)  
Old 11-26-2007
sachin.tendulka sachin.tendulka is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 32
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 (permalink)  
Old 11-26-2007
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
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 (permalink)  
Old 11-26-2007
varungupta varungupta is offline
Registered User
  
 

Join Date: Feb 2007
Location: Pune, Dehradun (INDIA), Michigan(US)
Posts: 206
Quote:
Originally Posted by sachin.tendulka View Post
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: *******

  #6 (permalink)  
Old 11-26-2007
Cameron's Avatar
Cameron Cameron is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2001
Location: Brisbane, Australia
Posts: 500
Would be interested in seeing your script.
Expecting postive response..

Cheers,
Cameron
  #7 (permalink)  
Old 11-26-2007
sachin.tendulka sachin.tendulka is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 32
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:46 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0