I need to send multiple files to a remote server via sFTP. I had everything set up to connect and send a single file automatically using a batch file and key authentication. Recently, however, the process has changed and we now need to send multiple files, one at a time, pausing for up to ten minutes in between files. I am having trouble passing a variable from my .ksh script to the sftp command. Once I pass control over to the batch file for sftp, it only recognizes sftp commands. I can't use a wildcard like "file*.RPT" because it will send all of the files up at once, without pausing in between them.
Does anyone have any experience scripting with sFTP that can shed some light on this for me?
Looks like a job for a here-document. I don't use sFTP but in old fashioned unsecure ftp you would do something like:
The commands between <<EOF and EOF (you can use any character string but the start and end strings must be identical with no leading/trailing spaces) are executed as if you typed them in at the keyboard
Looks like a job for a here-document. I don't use sFTP but in old fashioned unsecure ftp you would do something like:
hope this helps
cheers
Thanks, but sFTP works a bit differently than standard FTP. In order to run the sFTP script from cron, unattended, you must use sFTP with a batchfile. The batchfile only understands sFTP commands. It will not interpret variables, etc. You can't script sFTP inline like you can with standard FTP.
To sleep for any amount of time, you would have to run a sleep command. Why don't you use a batch file. Try doing this:
I tried that, but I need to handle multiple, unique filenames. In your example, how would you handle sending three files named issue8, issue23 and issue989 if you had to send them separately, sleeping for a given time in between each?
I can't pass the filenames from my script to the sFTP batchfile using variables or any "for filename in" construct. Once you pass control off to the sFTP batchfile, it only understands sFTP commands.
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
I have a .ksh script that creates an sftp batch file and runs it through sftp. It works except for one thing. If I try to "put" to a different name, it doesn't use the specified remote name...it still "puts" the original local name.
I've tried both of these, and neither work...it will always... (4 Replies)
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
hello All,
I am new user to shell scripting, kindly advise on the below?
I have a file where i have gaps & the delimiter falls in next line and new line is also created , plz see the example :employee.txt
Now the issue here is , i wan to write a script , where i can use "|" to get the... (6 Replies)
I have to pull multiple line records with ^ as the record separator(RS)... # should be my field separator (FS)...
Sample record is:
^-60#ORA-00060: deadlock detected while waiting for resource
ORA-00001: unique constraint (SARADM.TCKNUM_PK) violated#PROC:AVAILABLE_FOR_GETNXTTIC#02/27/2012... (7 Replies)
Hi Experts ,
I am new to unix programming please tell me how to write expect and hoe to call it for automated file upload process.
help me really ! (0 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Hi,
I've got a C program that is using execlp to run a non-interactive sftp (using a batchfile) session to send some files to another system.
Just before doing that, I create the batchfile called sftp_batch on the fly:
V8_26_1:sun-->cat /workspace/sftp_batch
cd /tmp/newsftp
put test.file... (2 Replies)