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. |
my opinion is that sftp prompts human users for keyboard input. whereas scp is designed for machine automation.
i think generically the problem is that the heredoc invokes a subshell in which $1 is not within its scope. |
Quote:
|
All times are GMT -5. The time now is 05:18 PM. |