The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Count and Auto FTP dappa UNIX for Advanced & Expert Users 3 06-13-2007 05:30 AM
auto decode a value to different value nhatch Shell Programming and Scripting 2 05-16-2007 01:01 PM
auto mail ahmad_one SUN Solaris 1 05-03-2006 07:07 PM
auto run whatisthis Shell Programming and Scripting 1 11-24-2004 07:12 PM
Auto Login merlin UNIX for Dummies Questions & Answers 1 11-20-2002 12:01 PM

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 09-20-2007
Ehab Ehab is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 23
su auto run help

how can I make auto run through script the comand SU - username
and given password
  #2 (permalink)  
Old 09-20-2007
sysgate's Avatar
sysgate sysgate is offline Forum Advisor  
Unix based
  
 

Join Date: Nov 2006
Location: Bulgaria
Posts: 1,323
with TCL/expect - drawback - you need to store root pass in file. Example :

Code:
spawn su -
expect ?assword:
send "root-pass-here\r"

or else use sudo
  #3 (permalink)  
Old 09-23-2007
Ehab Ehab is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 23
thanks

thaks Sysgate but the code expect not work
  #4 (permalink)  
Old 09-24-2007
sysgate's Avatar
sysgate sysgate is offline Forum Advisor  
Unix based
  
 

Join Date: Nov 2006
Location: Bulgaria
Posts: 1,323

Code:
#!/usr/bin/expect  #--- the place for expect executable, replace respectively on your system

set timeout -1  #--- sets the timeout to unlimited

spawn su -  #--- invoke system command, takes little time

expect assword:  #--- what to expect, the word password should be escaped

send "$pass\r"  #--- send string to expect buffer

send "exit\r"
expect eof  #--- both self-explanatory

Let me know what errors you see executing this script, whether you have expect installed, etc...
Also, let us know what is your OS, basically, what you have to do, is to simulate session for "su -" command.
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 01:18 PM.


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