The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
shell script to execute user command redtiger Shell Programming and Scripting 1 04-30-2008 06:53 PM
Executing script with root privilages from a user login checkpro SCO 1 03-11-2008 06:03 PM
CDE login Problem for root user only Awadhesh HP-UX 1 08-02-2005 08:58 AM
mistyped shell path, now i can't login as the only user that can su to root xyyz UNIX for Dummies Questions & Answers 3 10-22-2002 04:35 PM
No user able to login except root(superuser) konda UNIX for Advanced & Expert Users 2 06-25-2002 12:19 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-29-2008
pradeepreddy pradeepreddy is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 66
login into root from user and execute command through script

i have logged in as user.

I want to write a script to login into root and execute commands for eg. ifconfig or other command.

kindly help me out.
  #2 (permalink)  
Old 08-29-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
sudo should allow you to do what you require.
  #3 (permalink)  
Old 08-29-2008
palsevlohit_123 palsevlohit_123 is offline
Registered User
  
 

Join Date: Aug 2008
Location: India-Chennai
Posts: 120
$ cat myscript.ksh
ssh -l root HOSTNAME
echo "WELCOME to ROOT"
<do your stuff>
exit


$ sh myscript.ksh >> myscript.log

Will prompt for the password of root and you have to give manually.
  #4 (permalink)  
Old 08-29-2008
pradeepreddy pradeepreddy is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 66
i know the password of root.

I want to write the script in such a way that it should not promt for the passwd and directly login into root

i dont think host name is required. Because i am working in same system.
  #5 (permalink)  
Old 08-29-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
If any user would be allowed to run that, try a SUID script.

With sudo, you can control who can execute the command as root, and whether or not they need a password for that.
  #6 (permalink)  
Old 08-29-2008
pradeepreddy pradeepreddy is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 66
can u explain in detail
  #7 (permalink)  
Old 08-29-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
sudo tutorial - Google Search
Sponsored Links
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 10:34 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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