Using variables in SFTP
ok I'm new to linux scripting but not new to programming.
Gotten most of this from google searches:
-----------------------------------------------------
#!/bin/bash
#argument, MMYYYY of previous month
#some stuff, $1 variable works fine here
sftp [location] << 'ENDSFTP'
cd [location]
get *$1*.txt
ENDSFTP
#other stuff down here
----------------------------------------------------------
If I want to use the input variables like $1 it works fine outside the sftp block, but inside when I try to do this it is not replacing $1 with the script argument variable. Basically someone else puts this text file on their server and as part of my script I want to be able to do this with an argument and not have to change the code every month. I have similar code to do this that is daily. One approach I've done is just getting *.txt and then deleting all the other ones using the variable outside the sftp block but there's got to be an easier way right?
Thanks.
|