Quantcast
Channel: Active questions tagged expect - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 158

How to give file name as current date in expect

$
0
0

I have wrote a script in expect as follows. I want to give date as variable to cd command but when I am giving the date as variable to the command and it add '' commas and therefore it shows a error as follows. How to get rid of those commas?

#!/usr/bin/expect#!/bin/bashset DATE [exec date +%c]set DATE2 [exec date +'%Y%m%d']log_user 0log_file -a /lch/portal/scripts/sftpcheck21/log/sftpcheck21.logsend_log "test ran on $DATE \n"spawn sftp -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" -o "Port=8022" lchsftp22@lch.com@sftapx21expect "lchsftp22@lch.com@sftapx21's password:"send "London@123\n"expect "sftp>"send "cd /PIMCOXXX_FDM/SwapClear/$DATE2\n"expect "sftp>"send "lcd /lch/portal/scripts/sftpcheck21\n"expect "sftp>"send "get 'P-PSWC-PIMCOXXX_FDM-$DATE2-233518_$DATE2_REP000F1d - Trade Level Pricing_ 1.TXT'\n"expect "sftp>"send "exit\n"interactlog_file

output as follows

sftp> cd /PIMCOXXX_FDM/SwapClear/'20220130'Couldn't canonicalize: No such file or director

Viewing all articles
Browse latest Browse all 158

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>