- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- help with expect in shell script in 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
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
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
07-28-2004 03:31 AM
07-28-2004 03:31 AM
I have a shell script which starts with calling an expect script that ftps a file.Then the awk scipt does some parsing on this file and finally again an expect script is called to run sqlldr to load the data into a tabele in oracle. When I run this script from command line everything runs as desired. But when I put it in cron to run every 5 minutes then it fails. I see in the cron log file rc=127. what does that mean and please provide any way to make this work.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 03:38 AM
07-28-2004 03:38 AM
Re: help with expect in shell script in cron
eg:
00 00 * * * your_script > your_log 2>&1
If not, it is worth adding this so that you capture as much information as possible.
If you aren't already logging, some information should be passed to the mail file for the user running the job - check in /var/mail
You'll probably find that the cause of the problem is an environment variable that is set when you run the script from the command line, but not when you run it from cron.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 03:40 AM
07-28-2004 03:40 AM
Re: help with expect in shell script in cron
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 03:46 AM
07-28-2004 03:46 AM
Re: help with expect in shell script in cron
tst; echo $?
ksh: tst: command not found
127
Try to redirect all results of the shell script to a log file. Use set -x to debug the shell script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 04:28 AM
07-28-2004 04:28 AM
Re: help with expect in shell script in cron
Thanks for your responses.So now what I started doing was to break my complete solution into parts and start testing it.
I have the follwoing expect script which tries to ftp. When it is called from command line it just works perfectly fine but it is failing in cron. In crontab -e I have given it as /usr/local/bin/expect /home/saurabh/ftp
So I have specified the complete paths.
I also tried to redirect the output toa file using the command as below in cron, but it does not log anything into the croneradsout file.
02,08,14,20,26,32,38,44,50,56 0-23 1-31 1-12 0-6 /usr/local/bin/expect /home/saurabh/scripts/erads/MRerads/test/MReradsftp /tmp/croneradsout 2>&1
spawn "/bin/sh"
send "ftp
sleep 1
expect "Name\r"
send "node1\r"
sleep 1
expect "Password"
send "123\r"
sleep 2
expect "ftp"
send "cd \$dsmscm.trainer\r"
sleep 2
expect ""
send "ascii\r"
sleep 3
expect ""
send "get ECURRENT \r"
sleep 7
expect "ftp"
send "bye\r"
send "\r\r"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 05:00 AM
07-28-2004 05:00 AM
Re: help with expect in shell script in cron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 05:51 AM
07-28-2004 05:51 AM
Solutioni mean the command should be
do you have it in crontab?
Also to automate ftp you don't need expect, try the script attached, changing username, password and ftpserver as needed
hope it helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 06:07 AM
07-28-2004 06:07 AM
Re: help with expect in shell script in cron
Execute your profile before the script in the cron job,
02,08,14,20,26,32,38,44,50,56 0-23 1-31 1-12 0-6 . /etc/profile;. ./.profile; /usr/local/bin/expect /home/saurabh/scripts/erads/MRerads/test/MReradsftp >/tmp/croneradsout 2>&1
Hope this helps.
Regds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2004 06:51 AM
07-28-2004 06:51 AM
Re: help with expect in shell script in cron
Thanks for your Ftp script..that works perfectly and I could get rid of expect over there.
Now I put it in cron and it works there too...
I will have to now only get rid of expect for sqlldr.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2004 12:53 AM
08-09-2004 12:53 AM
Re: help with expect in shell script in cron
Some days spent in vacation. One more hint, you really need expect only when you have to automate a process in a way that could change (ex. my script would not be usable if you want to take care about errors while running ftp: server not responding, file not found etc.) or when the process you are running does not use standard input in standard way (ex. it closes it and reopen before using, see the command passwd).
In any other case the concept of my script (called hereby document) is general and can be use with any command
ex.
cat <
This text will be put in the file pippo
the variable $HOME will be substituted
the command $(pwd) will be substituted
ENDOFCAT
This is to say that probably you can write a script to automate both operation, ftp and access to db if you meet conditions exposed before
hope this helps