Calling Expect Script From a Perl Program, the perl program works fine
when executed in foreground (i.e on command line) but its does not
working in back ground (i.e schedule in a cron)..but if I call the same
expect script from a shell program it works both in back ground and
foreground. Your help is appreciated


Remote_ftp.exp 
#!/usr/local/bin/expect -f 
set force_conservative 0  ;# set to 1 to force conservative mode even if

                          ;# script wasn't run conservatively originally

if {$force_conservative} { 
        set send_slow {1 .1} 
        proc send {ignore arg} { 
                sleep .1 
                exp_send -s -- $arg 
        } 
} 
set timeout -1 
set rem_host [lindex $argv 0] 
set rem_user [lindex $argv 1] 
set rem_pswd [lindex $argv 2] 
set lcal_file [lindex $argv 3] 
set rem_file [lindex $argv 4] 
spawn $env(SHELL) 
match_max 100000 
expect  "> " 
send -- "ftp $rem_host\r" 
expect  "Name *: " 
send -- "$rem_user\r" 
expect "Password: " 
send -- "$rem_pswd\r" 
expect  "ftp> " 
send -- "bin\r" 
expect "ftp> " 
send -- "send $lcal_file $rem_file\r" 
expect "ftp> " 
send -- "bye\r" 
expect "> " 
send -- "exit\r" 
expect eof 

Remote_ftp.pl 
#!/usr/local/bin/perl 
localFILE='/tmp/test99'; 
remFILE='/tmp/test99'; 
$command="/export/home/scripts/remote_ftp.exp server1 user1 mypwd
$localFILE $remFILE"; 
$output = `$command`; 
print $output 

Remote_ftp.sh 
#!/usr/bin/ksh 
/export/home/perl/remote_ftp.pl 

Reply via email to