sftp in cron


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers sftp in cron
# 1  
Old 11-13-2008
PHP sftp in cron

Hi,

I am running simple script to automate sftp transfer to remote box. I have setup public/private keys to have sftp connect automatically and have test script that list remote directory:

Code:
#!/bin/ksh

echo "OK, starting now..."

  sftp userid@host <<EOI
  cd dir
  ls -lt
  bye
EOI

When I run script manually everything is ok and script executeds properly with output:

Code:
OK, starting now...
sftp>   cd dir
sftp>   ls -lt

<dir list>

sftp>   bye

When run through cron I get only the following:

Code:
OK, starting now...

Can anyone tell me what I am doing wrong or where the problem sits?Smilie
# 2  
Old 11-13-2008
Use the seach function of the forum please and have a look here maybe:
https://www.unix.com/answers-frequent...n-crontab.html
# 3  
Old 11-14-2008
Thanks for the link - this is very useful info.

It does also what I already found out. I just need to set PATH for the script to match the one in my .profile file.

Thanks!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sftp : not able to print the echo statements after the sftp transfer

I had the below sftp script working perfectly but the problem is I am not able to send the echo statements . #!/bin/sh echo "Starting to sftp..." sftp admin@myip << END_SCRIPT cd /remotepath/ lcd /localpath/ mget myfiles*.csv bye END_SCRIPT echo "Sftp successfully." echo echo... (11 Replies)
Discussion started by: scriptscript
11 Replies

2. Red Hat

Chroot sftp users, remote sftp login shows wrong timestamp on files

Hello, I have a weird issue, I have RHEL 5.7 running with openssh5.2 where sftpgroup OS group is chroot. I see the difference difference in timestamp on files, when I login via ssh and SFTP, I see four hour difference, is something missing in my configuration. #pwd... (8 Replies)
Discussion started by: bobby320
8 Replies

3. Shell Programming and Scripting

SFTP-how to log individual sftp command error while executing shell script

Hi, I have situation where i need to automate transferring 10000+ files using sftp. while read line do if ; then echo "-mput /home/student/Desktop/folder/$line/* /cygdrive/e/folder/$line/">>sftpCommand.txt fi done< files.txt sftp -b sftpCommand.txt stu@192.168.2.1 The above... (1 Reply)
Discussion started by: noobrobot
1 Replies

4. UNIX for Advanced & Expert Users

SFTP Not Working With CRON

Hello - I have a production stream that is scheduled with cron to run each Monday morning. The jobs in the stream perform tasks including FTP get, load to a DB table, and report processing. About a month ago I was directed to begin using sftp in these jobs and since then the jobs... (12 Replies)
Discussion started by: PatrickPurfield
12 Replies

5. UNIX for Dummies Questions & Answers

Problem automating sFTP transfer using script in cron

Hi Newbie here I am having problems with automating sFTP transfers. Just to save time - SCP is not an option as sFTP is stipulated by controllers of far end server. Ineed to automate sFTP transfer of a single file, once a day to a remote server to which i have no control over. I am using:... (6 Replies)
Discussion started by: robbien
6 Replies

6. UNIX for Dummies Questions & Answers

Unable to sftp with cron (once more time...)

Hi, I have been searching for older posts and I've found many entries with identical problems, but I was not able to find the solution (or when I thought I found it, my trial didn't worked :(). Anyway, here is my question. I wrote a sftp.sh file that runs perfect from command line. It uses scp... (6 Replies)
Discussion started by: Kronos
6 Replies

7. AIX

AIX and cron logs filtering ?: /etc/cronlog.conf, /var/adm/cron/log

Hi, I can use 'crontabs –e' and do all the scheduling I like. However I would like to auto send myself just the cronjobs logs that fail. That is to say the PIDs that fail and the related lines with those PID’s only. (Not the full set of logs) Has anyone done this work? Or does an AIX 5.3 tool... (0 Replies)
Discussion started by: Keith Johnson
0 Replies

8. Solaris

SFTP not exiting when run from cron

I am using a script to transfer a file from a unix host to another unix host. The code snippet for sftp in the script is as below. sftp -oIdentityFile=$ID_FILE_NAME -oNumberOfPasswordPrompts=0 $REMOTE_USERID@$REMOTE_HOST <<EOF cd incoming put $REPORT_FILE... (2 Replies)
Discussion started by: msabhilash
2 Replies

9. Shell Programming and Scripting

SFTP not working in cron

Hi, I have a simple script that is trying to put a file that resides on a local machine to a remote machine. It runs fine manually but does not complete when scheduling to run in cron. Here is what the script looks like. Any idea what I am doing wrong here? #!/bin/ksh cd /path sftp... (4 Replies)
Discussion started by: ewilson0265
4 Replies

10. Solaris

SFTP errorcode 1 when run on cron but runs manually

I am trying to run a sript on cron to SFTP data to a company. Private and public keys are set up. When I run this manully it works fine, however it was failing when run on cron. I have narrowed down the problem - it fails at the code that says if the error code is 0 then continue . . . I... (2 Replies)
Discussion started by: Heidi.Ebbs
2 Replies
Login or Register to Ask a Question