The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
sftp not working as cronjob tungaw2004 UNIX for Dummies Questions & Answers 3 01-10-2008 08:27 PM
Cron not working manna UNIX for Dummies Questions & Answers 1 01-10-2008 02:04 PM
SFTP not exiting when run from cron msabhilash SUN Solaris 2 12-02-2007 07:48 PM
SFTP errorcode 1 when run on cron but runs manually Heidi.Ebbs SUN Solaris 2 08-08-2007 12:16 PM
Cron not working? christo16 UNIX for Dummies Questions & Answers 5 03-09-2007 02:55 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-28-2006
ewilson0265 ewilson0265 is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 2
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 remoteuser@remotehost:/path <<EOF
mput Test.txt
bye
  #2 (permalink)  
Old 06-28-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
Code:
#!/bin/ksh
cd /path
sftp remoteuser@remotehost:/path <<EOF
mput Test.txt
bye
EOF
I'm assuming that leaving off EOF was a typo.

sftp used that way requires that authentication keys be set up on the remote host.
What local user is authenticated to remoteuser on the remotehost? And is the script running as that user, ie., do you su to the required local user?
  #3 (permalink)  
Old 06-28-2006
ewilson0265 ewilson0265 is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 2
Jim,

Thanks for your reply. We have generated keys on both the source and destination machines authenticating the user. We are running the script from this user. If I type it manually from a command prompt "TestSFTP.sh", it works fine. However when I put it in cron it doesn't.

As a further test, I put in an additional line in cron to send me an email.

#!/bin/ksh
mailx -s "Test" myemail@myemail.com < /path/TestSFTPcron.txt
cd /localpath
sftp remotename@remotehost:/remotepath <<EOF
mput Test.txt
bye
EOF

When I do this, it also works completely fine when I run it manually. However, in cron I so receive the email but the file is not put on the remote machine.

It looks like the script is partially working...

Last edited by ewilson0265; 06-28-2006 at 03:56 PM..
  #4 (permalink)  
Old 06-28-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
okay - you need to have the script run by cron as that user - use the man page for su to show you how to do that.
  #5 (permalink)  
Old 12-02-2007
msabhilash msabhilash is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 2
Hi,

Have you go this problem resolved ? even I am facing a similar problem. My script works fine when run manually from command prompt, but it is failing when put in to the crontab. How did you fix this problem?

Thanks.
Abhi.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 04:53 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0