I have few queries in expect..
I'm using expect script and I need to pick the password from a different file..
1) I'm able to do it.. but for one of my connection the password starts with # (hash mark) hence its picked.. I use the below command
set pwfl [open "/tmp/test/m1"]
set pw [read "$pwfl"]
2) how to set the format for date in the log file.. I use the below.. [exec date]_log file.. but the date format alone needs to be changed
!/usr/bin/expect -f
set pwfl1 [open "/tmp/test/m2"]
set pw1 [read "$pwfl1"]
set pwfl3 [open "/tmp/test/m4"]
set pw3 [read "$pwfl2"]
log_file [exec date]_Ext_Push_FTP.log
spawn sftp -v -o Port=122 -o IdentityFile=/tmp/test/SSH_PrivateKey_SFTPTesting.openssh -o PasswordAuthentication=yes t_rt_ext_push_sftppak_p@************
set timeout 15
expect "Enter passphrase for key '/tmp/test/SSH_PrivateKey_SFTPTesting.openssh':" {send "$pw3\r"}
set timeout 30
expect "t_rt_ext_push_sftppak_p@e********'s password:" {puts "$pw1\r"}
expect "sftp>" {send "put Sample_RT_Ext_Push_SFTPPAK.txt\r\n"}
expect "sftp>" {send "!echo Test file has been uploaded successfully by whoami
at date
>> Ext_Push_SFTPPAK.ftp\r\n"}
expect "sftp>" {send "bye\r"}