Hi,

I have never used sftp, but from the man page it looks like the sftp
commands need to be in a separate file. Something like:

fetch2.sh:
#!/bin/sh
sftp -b /home/jungle/batchfile jungle@host

/home/jungle/batchfile:
cd /home/jungle
put file_*.csv aaa_completed


If it were me, I would just use scp in my crontab, something like:

0 1 * * * /usr/bin/scp /home/jungle/file_*csv jungle@host:/usr/home/jungle/


...or maybe rsync if the file is large.


-Barry

On Fri, May 15, 2015 at 4:07 PM, jungle Boogie <[email protected]>
wrote:

> Hello All,
>
> Running Openssh's sftp version 3 on both client and server but the OS
> is not openBSD.
>
> I want to upload a file automatically with a cron job so I'm using the -b
> flag.
>
> % cat fetch2.sh
> #!/bin/sh
>
> cd /home/jungle
> put file_*.csv aaa_completed
>
>
> I can't specify the file name completely because it changes monthly
> (based on the month & year), but using batch file results in the file
> not being uploaded. When I connect directly, I can use the * just
> fine:
>
> % sftp jungle@host
> Connected to host.
> sftp> cd home/jungle
> sftp> put file_*.csv
> Uploading  file_foo2015-05-15.csv to
> /usr/home/jungle/file_foo2015-05-15.csv
> file_foo2015-05-15.csv
>
>
>
> Any ideas how I can achieve the latter with the former?
>
> Thanks,
> Jungle
>
> --
> -------
> inum: 883510009027723
> sip: [email protected]
> xmpp: [email protected]

Reply via email to