problem with expect


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting problem with expect
# 1  
Old 01-04-2011
Java problem with expect

i have written simple expect script but it doesnt work the way that i want can someone suggest wat is the issue?

Code:
#!/usr/bin/expect
spawn ssh abc@abc
expect "password:"
send "xyz\r"
expect "$"
send "mkdir hello\r"
#sleep 10
#exit 0

output
---------------

it does not create directory hello

Code:
[root@pqr ~]# ./login
spawn ssh abc@abc
Warning: Permanently added 'abc' (RSA) to the list of known hosts.
abc@abc's password: 
Last login: Tue Jan  4 10:18:06 2011 from mno
xhost:  unable to open display ""
-bash-3.2$ [root@pqr ~]# 
[root@pqr ~]#

Moderator's Comments:
Mod Comment please use code tags!

Last edited by DukeNuke2; 01-04-2011 at 05:06 PM..
# 2  
Old 01-04-2011
you give expect "$" and the system gives Last login: Tue Jan 4 10:18:06 2011 from mno xhost: unable to open display ""
so this is not the expected answer.
# 3  
Old 01-04-2011
actually the log in happens which you can see

Last login: Tue Jan 4 10:18:06 2011 from mno
xhost: unable to open display ""
-bash-3.2$

but after the expect "$" send command does nt get executed

send "mkdir hello\r"
# 4  
Old 01-04-2011
my last answer stays...

Code:
Last login: Tue Jan 4 10:18:06 2011 from mno
xhost: unable to open display ""
-bash-3.2$

!=

Code:
$

# 5  
Old 01-04-2011
i get what you mean. but can you please suggest something that can help me in moving further? i mean go into the prompt and execute the command in linux machine?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash expect problem

Hey there :) I have a Bash Script and I'm trying to update Roundcube, but theres a user interactive line like: bin/installto.sh /var/www/mail/rc Upgrading from 1.1.3. Do you want to continue? (y/N) I'm trying to avoid this user interaction like this: cd roundcubemail-1.2.1 >/dev/null... (5 Replies)
Discussion started by: Aeris
5 Replies

2. Shell Programming and Scripting

Problem with expect script

expect { -re "(.*)NEXT PAGE(.*)" { send "\r\n" } exp_continue (0 Replies)
Discussion started by: sagar_1986
0 Replies

3. Shell Programming and Scripting

expect script problem

Hi, Have strange problem. When I run an expect script towards a switch, it will not work. $ ./test2 spawn ssh admin@sesafdd101 Password: Last login: Thu Dec 25 13:20:54 2008 from 172.20.96.14 ECN430/330/212 Linux, based on Wind River Linux glibc_small (standard) 2.0 Trying... (1 Reply)
Discussion started by: etxnreg
1 Replies

4. UNIX for Dummies Questions & Answers

Problem in Expect

Hi Im writing an expect program for automating ftp. Having trouble with mget: expect "ftp>" {send "mget *.txt\r"} expect "mget*?" {send "n\r" ; expect_continue} expect "ftp>" {send "bye\r"} But expect even on ftp prompt "n" gets sent Please help... (1 Reply)
Discussion started by: crackle1985
1 Replies

5. Shell Programming and Scripting

expect problem

hi all, guys i have a problem in this code... any help ? #!/usr/bin/expect if { $argc != 3 } { puts "Usage:" puts "$argv0 username oldpwd newpwd" exit } #set machine set username set oldpwd set newpwd set completed_list " " (2 Replies)
Discussion started by: b1sh0p
2 Replies

6. Shell Programming and Scripting

sftp expect timeout problem

hello All, I am doing SFTP using expect. We just change our server from sun solaris 8 to sun solaris 10. The script was working good on sun solaris 8. But it is giving problem on 10. from shell, SFTP is working fine.Please help me. What can be the problem. LIB_sftp_get() { ... (0 Replies)
Discussion started by: mindtee_abhi
0 Replies

7. UNIX for Dummies Questions & Answers

Strange expect problem

Hi I'm writing a script which calls an expect script to retrieve configuration files for network devices. I want to avoid using TFTP to transfer the configs if possible and so I'm redirecting the screen output to a text file. This is the expect script: #!/usr/local/bin/expect set... (2 Replies)
Discussion started by: Ant1815
2 Replies

8. AIX

Problem with expect.

Hi, I am facing a strange problem while executing a script from a solaris server. This script calls another one to execute "expect" commands on some other 40 servers (all AIX 5200). I am passing username and password to the "expect" script as arguments. My problem is that it is showing the... (4 Replies)
Discussion started by: gsabarinath
4 Replies

9. Shell Programming and Scripting

Expect script problem

Hello all you scripting Gurus, I have an expect script that gets called from an AppleScript Studio app that basically takes arguments for user name, password, and server address and then calls rsync. Everything works wonderfully, EXCEPT (there had to be one of those) if the user name starts... (4 Replies)
Discussion started by: jdyck
4 Replies

10. AIX

problem with expect eof

hi guys i have such simple script, which i'm executing on AIX 5.3 #!/usr/local/bin/expect spawn passwd exptest set password 123 expect "*password:*" send "$password\r" expect "*password again:*" send "$password\r" expect eof the output is following: spawn passwd exptest sh:... (4 Replies)
Discussion started by: zoom
4 Replies
Login or Register to Ask a Question