su auto run help

Thread Tools Search this Thread
# 1  
su auto run help

how can I make auto run through script the comand SU - username
and given password
# 2  
with TCL/expect - drawback - you need to store root pass in file. Example :
spawn su -
expect ?assword:
send "root-pass-here\r"

or else use sudo
# 3  

thaks Sysgate but the code expect not work
# 4  
#!/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.

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #738
Difficulty: Medium
RadioShack introduced a 50 MB external hard disk for the TRS-80 Model III/4 in 1983.
True or False?

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 Dummies Questions & Answers

Scripts can be run manually but couldn't run with cronjobs

I am from MQ/MB technology. My requirement is to display the queue manger and broker status on daily basis. If I manually run the script, it works fine and displays output. But when I have scheduled the same using cronjobs it shows only the queue manger status and not the broker status. Can... (3 Replies)
Discussion started by: Anusha M
3 Replies

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

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

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

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

Featured Tech Videos