How to execute a program at expect script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to execute a program at expect script
# 1  
Old 07-10-2009
How to execute a program at expect script

what i need is that after passwordless enter another program should execute. I can succeed passwordless login but ı could not execute (./son) program. pls help me
# 2  
Old 07-10-2009
Did you read any of the many guides and howtos? I bet there is somewhere an example how to execute a program after login. Post what you got so far, ty.
# 3  
Old 07-10-2009
Try using ssh

ssh -l $UserName $RemoteHost command
# 4  
Old 07-10-2009
I want at expect script to execute another program for example:

#!/usr/local/bin/expect

spawn ssh root@172.30.64.163

expect "login:"
send "root\n"
expect "password:"
send "root\n"

send "./son" ----it does not work instead of this what should i write

interact
# 5  
Old 07-10-2009
Use CODE-tags when posting code, data or logs for better readability and to keep formatting/indention etc, ty.

Is "son" available on the destination machine?
What is the error you get?..
# 6  
Old 07-10-2009
"son" is available on the dest. machine. I dont get an error because the duty of send is writing what you write inside the " ". So it is printing ./son on the screen but it dont execute it.
# 7  
Old 07-10-2009
I am not using expect but having a short look into some tutorial I saw they often use \r when sending commands which looks like a enter stroke or something, like
Code:
send "./son\r"

If still nothing gets executed maybe try to add an "exec" inside the quotes in front of "son\r".

Check this
DeBaan: Simple expect ssh example
or any other of the 32.800.000 hits you get when you google for "expect tutorial".
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to execute commands on remote server using expect script?

I need to copy python script file to around 100 servers using expect script. 1. Copy script to my user home first(/home/myhome) on each remote server 2. change permissions on copied file to 766. 3. sudo to appuser1 account on remote server. copy script file from my user home to /usr/bin/... (1 Reply)
Discussion started by: kchinnam
1 Replies

2. Red Hat

Execute expect script during firstboot

closed (1 Reply)
Discussion started by: AbhishekAgrawal
1 Replies

3. Shell Programming and Scripting

Expect script to execute a script on a remote host

Hi, I am new to the expect scripting. I have this expect script as below : spawn ssh remote_server -l id set pass "12345" set opt "s" expect "Password:" {send "$pass\r" ; } expect "*ENTER*" {send "Enter\r"; exp_continue } expect "Please select option :" {send... (2 Replies)
Discussion started by: curt137
2 Replies

4. UNIX for Dummies Questions & Answers

Bash script to execute a program to rename files

I just can't figure it out , so please just give me a pice of advise how to: The existing Linux program foo2bar takes as its only argument the name of a single foo file and converts it to an appropriately-named bar file. Provide a script that when executed will run foo2bar against all foo... (4 Replies)
Discussion started by: raymen
4 Replies

5. Shell Programming and Scripting

how to execute a unix shell script from a java program

Hi All, well , i am facing this problem.. i have tried a few sample codes but there isn't any solution . could anyone please give a sample code as of how to do this... Please see the below details...and read the details carefully. I have written some code, logic is 1)from... (4 Replies)
Discussion started by: aish11
4 Replies

6. Shell Programming and Scripting

expect telnet script execute by cronjob

hi, please help, keep getting this bolded error and look it up and people say its your environment variable though i tried to set it manually in expect..it run fine if i run it manually but once i run it by cronjob it error below..i tried to comment out ip/login info with *.. logfile:: START... (0 Replies)
Discussion started by: cssanangeles
0 Replies

7. Shell Programming and Scripting

Help to write a script or program to automatic execute and link input file data

Output file template format <input_file_name>a</input_file_name> <total_length_size>b</total_length_size> <log_10_length_size>c</log_10_length_size> Input_file_1 (eg. sample.txt) SDFSDGDGSFGRTREREYWW Parameter: a is equal to the input file name b is equal to the total length of... (2 Replies)
Discussion started by: perl_beginner
2 Replies

8. Programming

C program to execute shell script

Hi, Can anyone give me a sample code to execute shell script from C program. Thanks (6 Replies)
Discussion started by: baigmd
6 Replies

9. Shell Programming and Scripting

C program to execute shell script

Hi, Can anyone pls give a sample to execute a shell script from C program Thanks (2 Replies)
Discussion started by: baigmd
2 Replies

10. UNIX for Dummies Questions & Answers

Script to open program and send/execute command in program

Hi, i want to write a script that executes a program (exec?) . this program then requires a filename as input. how do i give it this input in the script so the program will be complete run and close by the script. e.g. exec prog.exe program then asks for filename "enter filename:"... (1 Reply)
Discussion started by: tuathan
1 Replies
Login or Register to Ask a Question