From 959fba46d87d1a6ba02158c23d91009804e7e074 Mon Sep 17 00:00:00 2001 From: Waldo Jaquith Date: Sun, 31 Dec 2023 15:22:44 -0500 Subject: [PATCH] Set the path for CSV retrieval at deploy time --- cron/sftp.sh | 3 ++- deploy/sftp_credentials.sh | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cron/sftp.sh b/cron/sftp.sh index e332c00..b62c782 100755 --- a/cron/sftp.sh +++ b/cron/sftp.sh @@ -3,7 +3,8 @@ set filename [lindex $argv 0] set output_filename [lindex $argv 1] -spawn sftp {LIS_FTP_USERNAME}@sftp.dlas.virginia.gov:/CSV221/csv241/$filename $output_filename +# Seriously, the path contains "CSV221," no matter hwhat the year or session +spawn sftp {LIS_FTP_USERNAME}@sftp.dlas.virginia.gov:/CSV221/csv{SESSION_LIS_ID}/$filename $output_filename expect "password" send "{LIS_FTP_PASSWORD}\n" expect eof diff --git a/deploy/sftp_credentials.sh b/deploy/sftp_credentials.sh index 6e92469..ad196ef 100755 --- a/deploy/sftp_credentials.sh +++ b/deploy/sftp_credentials.sh @@ -3,4 +3,8 @@ # Set up FTP credentials in the SFTP script. sed -i -e "s|{LIS_FTP_PASSWORD}|${LIS_FTP_PASSWORD}|g" cron/sftp.sh sed -i -e "s|{LIS_FTP_USERNAME}|${LIS_FTP_USERNAME}|g" cron/sftp.sh -sed -i -e "s|{LIS_SESSION_ID}|${LIS_SESSION_ID}|g" cron/sftp.sh + +# Put the session ID into the SFTP path, so we fetch the correct LIS CSV +SESSION_LIS_ID=$(grep -oP "SESSION_LIS_ID', '\K([0-9]{3})" includes/settings.inc.php) +sed -i -e "s|{SESSION_LIS_ID}|${SESSION_LIS_ID}|g" cron/sftp.sh +