Re: sftp script put help

2015-05-17 Thread jungle Boogie
On 16 May 2015 at 01:19, Craig Skinner skin...@britvault.co.uk wrote:

 I used to have a script create batch files in /tmp,
 each with the full name of the incremental dump file to sftp.

 But I've found rdist. (OpenBSD uses ssh by default.)

 Look at rdist(1) EXAMPLES section, 
 http://www.benedikt-stockebrand.de/rdist-intro_en.html


Unfortunately, the sftp system I'll eventually be connecting to won't
have rdist, but I'll definitely try to use rdist for future usage.
Does it allow throttling?

Thanks for teaching me about rdist!

-- 
---
inum: 883510009027723
sip: jungleboo...@sip2sip.info
xmpp: jungle-boo...@jit.si



Re: sftp script put help

2015-05-16 Thread Thomas Bohl

Hello,

Am 16.05.2015 um 01:07 schrieb jungle Boogie:

I want to upload a file automatically with a cron job so I'm using the -b flag.



% 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


You can do it in a one-liner:

32 1 * * * printf \%s\n\%s\n cd /home/jungle put /path/*.csv | 
sftp jungle@host



regards



Re: sftp script put help

2015-05-16 Thread Craig Skinner
On 2015-05-15 Fri 20:58 PM |, Barry Grumbine wrote:
 
 I have never used sftp, but from the man page it looks like the sftp
 commands need to be in a separate file.

Yes.

I used to have a script create batch files in /tmp,
each with the full name of the incremental dump file to sftp.

But I've found rdist. (OpenBSD uses ssh by default.)

Look at rdist(1) EXAMPLES section, 
http://www.benedikt-stockebrand.de/rdist-intro_en.html





e.g: ~postmaster/distfile:

HOSTS = ( box1 box2 box3 box )

bin:
~/bin   - ${HOSTS}

spamd-trap-addresses:
/etc/mail/spamd.trap-addresses  - ${HOSTS}
special spamdba add -l -s ;

mx-backup-recipients:
/etc/postfix/recipients.list.box0   - box5
special logger -p mail.notice rdist of ${REMFILE} ;

...
..


e.g: postmaster's crontab:

RDIST_LOGGING='-l stdout=info,change,notice,nerror,ferror,warning'

32  2   *   *   Mon-Sat nice -n 18 rdist ${RDIST_LOGGING} -o 
verify bin spamd-trap-addresses
5   */8 *   *   Mon-Sat nice -n 15 
postfix-generate-recipients-list  nice -n 15 rdist ${RDIST_LOGGING} 
mx-backup-recipients

...
..


Cool.
-- 
Duct tape is like the force.  It has a light side, and a dark side, and
it holds the universe together.
-- Carl Zwanzig



sftp script put help

2015-05-15 Thread jungle Boogie
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: jungleboo...@sip2sip.info
xmpp: jungle-boo...@jit.si



Re: sftp script put help

2015-05-15 Thread jungle Boogie
Hi Barry,
On 15 May 2015 at 20:58, Barry Grumbine barry.grumb...@gmail.com wrote:
 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


Ah, that's excellent! Thanks!!


 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/


In my testing I'd be able to use scp or rsync but when I deploy, I'll
only have sftp available.

Thanks for trying this out and giving me input.


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


 -Barry



Best,
j



Re: sftp script put help

2015-05-15 Thread Barry Grumbine
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 jungleboog...@gmail.com
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: jungleboo...@sip2sip.info
 xmpp: jungle-boo...@jit.si