UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old May 27th, 2004, 05:13 AM
Tamper22 Tamper22 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 2 Tamper22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old June 3rd, 2004, 03:11 AM
Tamper22 Tamper22 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 2 Tamper22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy A bit of a cop out......

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

Reply With Quote
  #3  
Old June 9th, 2004, 10:02 PM
bingotailspin's Avatar
bingotailspin bingotailspin is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 115 bingotailspin User rank is Corporal (100 - 500 Reputation Level)bingotailspin User rank is Corporal (100 - 500 Reputation Level)bingotailspin User rank is Corporal (100 - 500 Reputation Level)bingotailspin User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 11 h 52 m 45 sec
Reputation Power: 7
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Shell scripts and ftp


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway