Help need for automation of su command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help need for automation of su command
# 1  
Old 10-14-2008
Help need for automation of su command

Hi All!
I need to automate the su command using expect script.Suppose I login as a user A , I need to change the user to oracle using the su oracle command and execute the command "sqlplus -ver".

I tried writing a expect script for the same , but can't figure out the reason it is not working.

Can someone please help. Below is the expect script that I wrote:

Code:
#!/usr/bin/expect -f
set timeout -1
spawn /bin/su oracle -c date 
expect "Password: " 
send "oracle\r"
expect "\r\n"
send "sqlplus -ver\n"

Thanks!
nua7
# 2  
Old 10-19-2008
sudo would be much easier than expect for this job... is that available for you?

Failing that, please show us the output you get when you run your expect script. You might consider using autoexpect to generate your script...?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

UNIX automation

I am using netteza server and i have a list of table names. I need to fetch all the data from these tables and need to create seperate zip files and store in a folder in the server. How can we automate this process. (1 Reply)
Discussion started by: nikhilthms97
1 Replies

2. UNIX and Linux Applications

Ansible Automation

Hi Gurus, I am new to ansible automation, kindly suggest me whether i am going in right path. I Want to automate deployment of apache,mysql-server on multiple Linux hosts. ansible version i am using ansible 1.5.4 OS: Ubuntu 14.04.5 LTS below is the Script created for the same --- -... (3 Replies)
Discussion started by: venky.b5
3 Replies

3. Shell Programming and Scripting

CVS Automation

Hi All, I am just looking for CVS automation for SQL scripts. Normally Devs will check in new sql scripts or they will update the existing sql scripts with new query. We will take the scripts from CVS and run in DB. I am thinking to automate that process like whenever a new script is checked in... (1 Reply)
Discussion started by: pvmanikandan
1 Replies

4. UNIX for Dummies Questions & Answers

CUPs automation

A little background information: We are a company that uses Sharp MFP devices for everyone to print on. We have a lot of MAC BYOD devices. All printing is done through a product called PaperCut which is ran on a Windows 2008 R2 server. Sharp charges our company for each print job done in... (1 Reply)
Discussion started by: jdmorecraft
1 Replies

5. Shell Programming and Scripting

automation using python

Im trying to write an automation script using python. I expect this script to log in to a remote server, execute commands and get its output. import pexpect child=pexpect.spawn('ssh myuser@192.168.151.80') child.expect('Password:') child.sendline('mypassword') get_output =... (4 Replies)
Discussion started by: Arun_Linux
4 Replies

6. UNIX for Advanced & Expert Users

Need help in automation

Hi, I wanted to automate the scp command where i do not want to enter the password each time. So thought of using expect command. Script is executing without any issues but files are not copied to remote server. Can any one help me? Below is my shell script.. #!/bin/ksh ... (6 Replies)
Discussion started by: balasubramani04
6 Replies

7. Shell Programming and Scripting

Automation of UI using shellscript

Hi, I want to do automation on UI using shellscript. eg: 1) Drop down menu contains assign , investigate, closed. now there is one id want assign it using assign tab then need to investigate it and lastly close. Sometimes the id can't assign to perticular user. there are so many... (11 Replies)
Discussion started by: aish11
11 Replies

8. Shell Programming and Scripting

Help in automation...

Hi All, I need to run the same command on many servers. I am using ssh for the same. Following is the script that I am using to fire the same command on multiple machines. #!/bin/bash # Linux/UNIX box with ssh key based login #SERVERS="iqmevrick,iqmango" # SSH User name USR="root" #... (1 Reply)
Discussion started by: nua7
1 Replies

9. OS X (Apple)

X11 automation?

I'm a newbie on OS X and Mac, I bought my first Mac (a Mini) in october last year, so bare with me. :) I usually run X11 to have aixterm displayed on my Mac, what I would like to do is to set a specific xhost + every time I start X11, for example xhost +10.0.0.2 every time I start X11. Also,... (1 Reply)
Discussion started by: dlundh
1 Replies
Login or Register to Ask a Question