su auto run help


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers su auto run help
# 1  
Old 09-20-2007
su auto run help

how can I make auto run through script the comand SU - username
and given password
# 2  
Old 09-20-2007
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  
Old 09-23-2007
thanks

thaks Sysgate but the code expect not work
# 4  
Old 09-24-2007
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.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Howto auto boot SPARC | How to auto supply "start /SYS" and "start /SP/console" commands

When I power ON my T4-1, I got a prompt -> where I have to start /SYS and start /SP/console. How can I auto supply these two commands ? (3 Replies)
Discussion started by: z_haseeb
3 Replies

2. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies

3. Shell Programming and Scripting

Run a command for specific amount of time with an auto key press

Hi, I have been trying to do a small fun project for myself. I want to run a command for 45 seconds. And to get the final output of this command, the script requires I push the "q" key on my keyboard and then the final output file becomes available. I tried the following script. But it... (12 Replies)
Discussion started by: jacobs.smith
12 Replies

4. UNIX for Advanced & Expert Users

has no rc.local in /etc, how to auto run cmd in the boot process?

Hi I want to run some cmd before the linux boot up and I want to let it run before sshd service start, any helps? (1 Reply)
Discussion started by: yanglei_fage
1 Replies

5. Shell Programming and Scripting

how to run an already made script run against a list of ip addresses solaris 8 question

how to run an already developed script run against a list of ip addresses solaris 8 question. the script goes away and check traffic information, for example check_GE-VLANStats-P3 1.1.1.1 and returns the results ok. how do I run this against an ip list? i.e a list of 30 ip addresses (26 Replies)
Discussion started by: llcooljatt
26 Replies

6. Shell Programming and Scripting

Auto run script on USB device

Okay I want to write a script that I put on a jump drive. And when you plug the USB in this script executes. How would i go about doing this? I don't care what the program does right now. I just want to know how this would be done. Any ideas? (1 Reply)
Discussion started by: cbreiny
1 Replies

7. AIX

My script didn't run every run every minute at cronjob

In my cronjob, I would like to schedule my script.sh to run every minutes. I crontab -e and have in line below but it didn't seems to run at all. * * * * * script.sh When I run it manually, I can run it. Is that anything wrong with the above line? If I change it to something like below,... (4 Replies)
Discussion started by: ngaisteve1
4 Replies

8. UNIX for Dummies Questions & Answers

Shell Script to Auto Run PHP Script

Hello All! I am looking to build a monitoring script. The script should always run as a system service of some type and should always check that a PHP script is running. Maybe there is a way to assign a PHP script to a certain PID so that the monitor script that check for the PID in top... (4 Replies)
Discussion started by: elDeuce
4 Replies

9. Shell Programming and Scripting

auto run

Hi, There is a excutable program on Linux server and requires user to input some numbers to take them go through different steps to do things. I need to make the process from manual to automatic. I wrote a file that have each steps already typied. When user runs the program, I make them use below... (1 Reply)
Discussion started by: whatisthis
1 Replies
Login or Register to Ask a Question