Sftp batch processing commands


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sftp batch processing commands
# 1  
Old 06-11-2014
Sftp batch processing commands

Hello,

I have a UNIX script to sftp batch processing. Here is my sftp command.
Code:
ftp -b toopc userid@sftp.hostname.com

In the file toopc I have the following commands:
Code:
mget *.csv
bye

This brings in all files with an extension of .csv

However, I need to only bring in files that

1. start with "435_193_"
2. todays date in year month day format
3. .csv extension.

example 435_193_20140611.csv

I have been having trouble figuring out the get command for this to work. Everything I try gets an error.

Please help.

John Schlinz


Moderator's Comments:
Mod Comment Please use code tags next time for your code and data. Thanks

Last edited by vbe; 06-11-2014 at 11:29 AM..
# 2  
Old 06-11-2014
correcting your line mget *.csv to
Code:
 mget 435_193_*20140611.csv

produces an error?
# 3  
Old 06-11-2014
Thanks VBE. The example may not be very clear. I will need to replace the hard coded date shown in example with a date function to get current date each time it runs. Something like this: mget 435_193_'date +%Y%m%d'.csv
# 4  
Old 06-11-2014
So you place the date value in a variable:
Code:
WANTEDDT=$(date +%Y%m%d)

and you use it after:
Code:
mget 435_193_*$WANTEDDT.csv


Last edited by vbe; 06-11-2014 at 01:07 PM..
# 5  
Old 06-11-2014
Hell vbe,

The variable set up works. However, it doesn't seem to be read correctly in command file. This is message I get.

Couldn't stat remote file: No such file or directory
File "435_193_$WANTEDDT.csv" not found.

Thanks.
# 6  
Old 06-11-2014
You need to call sftp not ftp for a start.

You may need to re-create the batch file in your shell script each time you run. Consider this:-
Code:
#!/bin/ksh

echo "mget *_`date%Y%m%d`" > toopc
sftp -d toopc userid@sftp.hostname.com

Does that help?



Robin
# 7  
Old 06-11-2014
That work! Thank you both very much.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Batch processing files through an interactive script

I am newish to the site and to unix. I have a functioning interactive script running on Mac that sorts and processes files located in an unsorted folder on my desktop. As it currently stands, the user types jpg into the command line, the script executes and iterates through the unsorted... (8 Replies)
Discussion started by: Braveheart
8 Replies

2. UNIX for Advanced & Expert Users

Batch SFTP command Help

I need to run a test SFTP command in a batch mode and what I need to prompt my password after the sftp userid@hostname. I do not have have an ssh key exchanged between my server and the external server. I only have access to it as an sftp server. I must enter my password in my script. How do i... (2 Replies)
Discussion started by: mrn6430
2 Replies

3. Shell Programming and Scripting

Batch script to run in SFTP

Hello Guys, I am writting a script which is SFTPing from Solaris to Windows. I need to run a Batch script in SFTP session (ongoing) which will map a network drive and then transfer my files. I can run the Batch script via SSH but not via SFTP and this mapping is limited to that SSH... (4 Replies)
Discussion started by: Deei
4 Replies

4. Programming

sftp batch programming

done for this. (4 Replies)
Discussion started by: leganti
4 Replies

5. Shell Programming and Scripting

How to batch-processing numerous shell scripts?

How to batch-processing numerous shell scripts? how to record the result of all the scripts as a report? then, I can analysis the process result. I want to process numerous shell scripts in my working directory: the directory name is consistent with shell scripts name, that is to say,... (2 Replies)
Discussion started by: qcmao
2 Replies

6. Shell Programming and Scripting

Batch file for sftp commands

I am trying to automate an sftp command so that it does not stop and ask for the password each time the calling shell script #!/bin/ksh sftp -b tst_1_batchfile.txt GLAXGBUPMPSOUT@204.90.134.116 the batchfile contents : password XXXXXX cd /GLAXGBUPMPSOUT/GSKENT/GLAXGF2FOPFF put... (4 Replies)
Discussion started by: Shrabanti
4 Replies

7. Shell Programming and Scripting

Processing different jobs as a batch process

Hi All, I want to process consecutive jobs in a sequence but when I execute 1 job ,the control does not return to the command prompt to continue with the next job. Can anyone help me here? Thanks (3 Replies)
Discussion started by: Taranjeet Singh
3 Replies

8. Shell Programming and Scripting

bash - batch processing folder of files by name

Hello Everyone!!! I need some help with a shellscript to batch process a folder of files with the imagemagick convert -append/+append command. The folder contains some hundred or thousand of small images in .png format which I would like to join together in order of their filenames. The... (3 Replies)
Discussion started by: imtombi
3 Replies

9. UNIX for Advanced & Expert Users

Sftp in Batch Mode

Hi, I am trying to do sftp a file from one server to another solaris server. Both are sftp enabled. I have generated the rsa key in local server and did a ftped the public key to the remote server and added that in the authorization keys file. Then i try to run the below command using a... (2 Replies)
Discussion started by: sivaemn
2 Replies

10. UNIX for Dummies Questions & Answers

SFTP batch script

Hi, I am running an sftp batch script. sftp -b user@host <<EOF >> /tmp/file.out binary put file.txt bye EOF However, I am getting errors. No such file or directory (user@host). I checked the forums which says I need to access the current process eg for linux I would... (3 Replies)
Discussion started by: Bab00shka
3 Replies
Login or Register to Ask a Question