|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
VeriSign Code Signing Digital Certificates provides assurance to end users. Read about this and more in the free white paper: “How to Digitally Sign Downloadable Code for Secure Content Transfer.” Learn More! |
|
#1
|
|||
|
|||
|
Shell scripts and ftp
Hi to anyone who can help me
I have a script that I would like to run as a cron job it simply creates a variable for the current day of the week and then uses this to transfer some files via ftp from a Unix server to a Windows NT server every 15 mins, now my problem is very similar to a thread made by someone else in the fact that from the command line all works well, but submitting the job via cron loses the "day" variable and so the files are transferred to the top directory. Not sure why this is so over to the experts (you) to answer this :-) My script is as follows:- #!/bin/bash date > /var/day set today=`cat /var/day | cut -c1,2,3` echo "today is $today" # output files transfered to ftp_log file cd /vol/rt11/interfile_out ls *.ihd > /var/ihdftp_log ls *.dat > /var/datftp_log # combine the date and files transferred into a combined log file cat /var/day /var/ihdftp_log > /var/combined_log cat /var/datftp_log /var/combined_log > /var/combined_cont_log cp /var/ftphist_log /var/hist.tmp cat /var/hist.tmp /var/combined_cont_log > /var/ftphist_log # Now move the files to correct location # Start FTP session cd /vol/rt11/interfile_out ftp -nv xxx.xxx.xxx.xxx > /var/ftplog22 << lab1 user xxxxx xxxxxx cd healthsci/nuclear/live/$today pwd prompt bin mdele *.IHD mdele *.DAT mput *.ihd mput *.dat bye lab1 /usr/xpg4/bin/rm /var/hist.tmp ________________ It is the $today variable that seems to be lost when running in cron. (xxxxx used for obvious reasons) Hope you can help |
|
#2
|
|||
|
|||
|
Having waited for any suggestions from you guys and not getting any response I have split the script into separate ones for each day and cron runs these ok.
A bit of a cop out as I still do not know why my script would run from the command line using the $today variable but not from cron. I guess its back to the books to learn more about shells ![]() |
|
#3
|
||||
|
||||
|
You can use date +%a to get the day of the week. The date executable is in the /bin directory (so is cat, but cut is sometimes in /usr/bin), so cron should pick it up. I usually look at path issues with cron, as most systems only have /bin in the cron path. Also, look in /var/cron/*log for errors or pipe the crontab through mailx to get debug info.
|
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Shell scripts and ftp |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|