- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Unable to use SFTP with CRON
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-10-2002 07:08 AM
тАО12-10-2002 07:08 AM
Unable to use SFTP with CRON
I am required to run an automated data feed using Secure FTP. To do this I decided to use the Expect Utility(since a password is
required). The Expect script runs fine from the commandline, but will not complete it's run using cron.
We use an HP-UX 11.0 OS, and I was able to get a simple Expect script using FTP(on a test machine) to run through cron, just when I attempt to use SFTP2 I run into problems.
The Expect script that I am running writes to a log file and it appears to break after the password has been entered.
The below lines are where the log file displays the first error that occurs:
remote path: Error: Connection was lost.
remote server failed.
Then, of course, the rest of the script begins failing from there.
I have this script checking to see if a controlling terminal exists, and it does for the commandline run, but does not for the cron job. I am not sure if this is where the problem occurs, and if it is I am unsure how I should set a controlling terminal.
Any ideas, examples of cron/sftp2/expect or recommendations on going in a different direction would be greatly appreciated.
Jay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-10-2002 07:41 AM
тАО12-10-2002 07:41 AM
Re: Unable to use SFTP with CRON
I'm trying to do it but have yet to succeed.
I'm actually trying scp.
The problem relates to getting a common public key on the target and remote system. Then you should be able to work it out.
I have an ftp script that works, but it requires a hardcoded password, so I don't use it much.
It will become a critical issue around here in about two months, so check back.
Steve
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-11-2002 12:42 PM
тАО12-11-2002 12:42 PM
Re: Unable to use SFTP with CRON
I tested out in my test environment and it works just fine. I am using RSA keys for ssh2.
...Manjeet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-12-2002 12:32 PM
тАО12-12-2002 12:32 PM
Re: Unable to use SFTP with CRON
Unfortunately, one of my requirements is to use a password for sftp.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-04-2003 08:48 AM
тАО02-04-2003 08:48 AM
Re: Unable to use SFTP with CRON
Jay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-04-2003 08:55 AM
тАО02-04-2003 08:55 AM
Re: Unable to use SFTP with CRON
In case you want enhanced security, you can exchange public keys.
attached.
P
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 12:14 AM
тАО02-01-2006 12:14 AM
Re: Unable to use SFTP with CRON
My status is that script executed from command prompt run OK.
When I execute script from crontab - sftp connection fails.
You wrote, that your script is running with cron after path have been set.
Please, could you specify "setting the path in the expect script".
thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 02:30 AM
тАО02-01-2006 02:30 AM
Re: Unable to use SFTP with CRON
Your chance of a reply from Jon Singleton here is slim.
Jon Singleton
Last contribution date: February 04, 2003
I am not an expect person myself.
export PATH=$PATH:/pathtosftp
might be in there somewhere.
Cheers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 03:35 AM
тАО02-01-2006 03:35 AM
Re: Unable to use SFTP with CRON
/
instead of
expect
in the scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 03:56 AM
тАО02-01-2006 03:56 AM
Re: Unable to use SFTP with CRON
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 07:04 PM
тАО02-01-2006 07:04 PM
Re: Unable to use SFTP with CRON
Hi Gavin, Admin,
thank you for your instant replays.
I use full path to expect utility in my script.
I wrote two scenarios:
1st - I am calling
/opt/expect/bin/expect -c ' ...... ' in my sh-script
(SHLIB_PATH, PATH variables were set correctly and exported.)
2nd - there is sh-script calling another script which starts with
#!/opt/expect/bin/expect
The both scenarious work OK, while I run script from the command line.(Doen not matter in which directory I am - no problem to run script from home directory or different one)
The only, problem is the calling script from cron.
there is log from my test SFTP server:
02-01-2006 09:52:20 IP 10.170.134.20 SFTP sftpuser connected
02-01-2006 09:52:20 IP 10.170.134.20 SFTP sftpuser is changing dir to / (D:\FreeFTPD\sftpuser\)
02-01-2006 09:52:20 IP 10.170.134.20 SFTP sftpuser is changing dir to /rm (D:\FreeFTPD\sftpuser\rm\)
02-01-2006 09:52:20 IP 10.170.134.20 SFTP sftpuser is listing /rm (D:\FreeFTPD\sftpuser\rm\)
02-01-2006 09:52:20 IP 10.170.134.20 SFTP sftpuser is listing /rm (D:\FreeFTPD\sftpuser\rm\test.txt)
02-01-2006 09:52:20 IP 10.170.134.20 SFTP sftpuser is listing /rm (D:\FreeFTPD\sftpuser\rm\test.txt)
02-01-2006 09:52:20 IP 10.170.134.20 SFTP sftpuser is downloading /rm/test.txt (D:\FreeFTPD\sftpuser\rm\test.txt)
02-01-2006 09:52:20 IP 10.170.134.20 SFTP sftpuser transfer complete
02-01-2006 09:52:20 IP 10.170.134.20 SFTP sftpuser disconnected
02-01-2006 09:54:01 IP 10.170.134.20 SFTP connection attempt
02-01-2006 09:54:03 IP 10.170.134.20 SFTP sftpuser disconnected
at 9:52:20 - srcipr run fromcommand line
at 9:54:01 - script sun from cron
any idea, please?
thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 07:22 PM
тАО02-01-2006 07:22 PM
Re: Unable to use SFTP with CRON
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 07:26 PM
тАО02-01-2006 07:26 PM
Re: Unable to use SFTP with CRON
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=757938
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-02-2006 04:11 AM
тАО02-02-2006 04:11 AM
Re: Unable to use SFTP with CRON
There will be something missing from cron's environment settings you will need to set them as part of the calling script. I guess.
The thread Muthu pointed out is suggesting that too.
Cheers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-05-2006 10:33 PM
тАО02-05-2006 10:33 PM
Re: Unable to use SFTP with CRON
Hello everybody!
Finally, the cron - sftp problem have been solved.
There was "cron - expect - sftp -b cmdFile" problem. The combination above does not work properly.
Solution is to move sftp commands from batch-command file directly to expect script
and do not use sftp -b, when you plan to run script with cron.
thank you
regards
Igor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-06-2006 12:00 AM
тАО02-06-2006 12:00 AM
Re: Unable to use SFTP with CRON
Seems like I lead you down the garden path. I'm sorry about that I certainly didn't intend to.
This will be a good resource for others now that you have posted the answer.
Cheers
Gavin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-12-2007 06:01 AM
тАО04-12-2007 06:01 AM
Re: Unable to use SFTP with CRON
After fighting with this for a week I found what works for me at
http://www.linux.org/lessons/interm/c316.html
I added "expect eof" after sending the password.
walt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-12-2007 06:25 AM
тАО04-12-2007 06:25 AM
Re: Unable to use SFTP with CRON
Please read ITRC ettiquette guidelines and stop bringing long dead threads to the top of the queue.
Regards,
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com