Re: expect in bash script ?



Chris F.A. Johnson wrote:

Exactly as shown in the part of the message you quoted, where
expect_script is the command that runs your script.


OK, maybe I don't understand something. Tell me what's wrong; here's the
example:

ver 1:
--------------
#!/bin/bash

var=$(expect ftp some.ftp.addres
expect "Name"
send "myname\r"
expect "Password:"
send "mypass\r"
expect "ftp>"
send "cd some_directory"
expect eof)

echo $var
--------------
result:
--------------
$ ./script.sh
couldn't read file "ftp": no such file or directory
couldn't read file "Name": no such file or directory
../script.sh: line 3: send: command not found
couldn't read file "Password:": no such file or directory
../script.sh: line 5: send: command not found
couldn't read file "ftp>": no such file or directory
../script.sh: line 7: send: command not found
couldn't read file "eof": no such file or directory
--------------

ver 2:
--------------
#!/bin/bash

var=$(expect ftp some.ftp.addres expect "Name" send "myname\r" expect
"Password:" send "mypass\r" expect "ftp>" send "cd some_directory\r"
expect eof)

echo $var
--------------
result:
--------------
$ ./script.sh
couldn't read file "ftp": no such file or directory
--------------

greetz,
T


--
"Przyjacielu, lepiej nas dobrze wypieprz zamiast prawić nam kazania.
Nawrócić nas nie zdołasz..." Marquis Donatien Alphonse François de Sade
.



Relevant Pages

  • Re: Kermit 95 ver 2.1 and SECURED FTP automated connection
    ... > We recently purchased Kermit 95 ver 2.1. ... > anonymously to a W2K3 server running SP1 and Microsoft ftp service/IIS ... > work against a W2K3 server or goes the ftp connection need to be made ...
    (comp.protocols.kermit.misc)
  • Re: ftp
    ... execute other commands.. ... normal shell after connecting the FTP ... the "quit" command.. ... If you want to run the command on the local server within the EOF ...
    (comp.unix.shell)
  • Kermit 95 ver 2.1 and SECURED FTP automated connection
    ... We recently purchased Kermit 95 ver 2.1. ... anonymously to a W2K3 server running SP1 and Microsoft ftp service/IIS ... if fail exit 1 Connection failed ...
    (comp.protocols.kermit.misc)
  • Re: Sheell Script for SFTP
    ... > EOF ... Hi Ian, ... FTP may be disabled can we the same functionality like transferring the ...
    (alt.os.linux.redhat)
  • Re: Opera 8.01 Segfault Problem
    ... > Downloaded the Ver 8.01 static rpm. ... > no missing libs. ... > ftp). ...
    (alt.os.linux.suse)