1842897 Members
2909 Online
110210 Solutions
New Discussion

Re: FTP PROBLEM

 
SOLVED
Go to solution
matthew mills
Frequent Advisor

FTP PROBLEM

I am building a script that produces some reports and then FTP’s the reports to a different server. I am using grep to grab some of the file names that I need in to a variable. But when I run the program in CRON it will not move the files with the variable. When I run it manually it works great! Please help!

export FLE1=`/bin/grep "PLAN/STATUS PART I " /tmp/stf91.tmp | /usr/bin/cut -c66-
80`
export FLE2=`/bin/grep "PLAN/STATUS PART II " /tmp/stf91.tmp | /usr/bin/cut -c66
-80`


echo "##FTP AFCOS DATA ########################################################"
/usr/bin/ftp -i -n 55.55.555.55 << !!
quote user michy
quote pass mouse
cd /afcos
put /webdata/comp/ordreg30.txt ordreg30.txt
put /webdata/comp/ordreg90.txt ordreg90.txt
put /comp/print/stanfins/$FLE1 finplan1.txt
put /comp/print/stanfins/$FLE2 finplan2.txt
bye
!!
3 REPLIES 3
Steven E. Protter
Exalted Contributor
Solution

Re: FTP PROBLEM

Shalom,

cron has no envrionment at all.

env > /tmp/normalenv.txt

then add this to your cron job.

env > /tmp/cronenv.txt

let cron run it.

diff /tmp/cronenv.txt /tmp/normalenv.txt

Best to have all commands in full path mode when running in cron.

Working template:

ftp -i -n $dbserver<<-FTP
user $username $password
cd $archpath
dir . file_list
bye
FTP

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
spex
Honored Contributor

Re: FTP PROBLEM

export FLE1=$(/bin/grep "PLAN/STATUS PART I " /tmp/stf91.tmp | /usr/bin/cut -c66-80)
echo ${FLE1} > /tmp/stf91-f1.tmp
export FLE2=$(/bin/grep "PLAN/STATUS PART II " /tmp/stf91.tmp | /usr/bin/cut -c66-80)
echo ${FLE2} > /tmp/stf91-f2.tmp

echo "##FTP AFCOS DATA ########################################################"
/usr/bin/ftp -i -n 55.55.555.55 << !!
quote user michy
quote pass mouse
cd /afcos
put /webdata/comp/ordreg30.txt ordreg30.txt
put /webdata/comp/ordreg90.txt ordreg90.txt
put /comp/print/stanfins/$(cat /tmp/stf91-f1.tmp) finplan1.txt
put /comp/print/stanfins/$(cat /tmp/stf91-f2.tmp) finplan2.txt
bye
!!
matthew mills
Frequent Advisor

Re: FTP PROBLEM

HP ROCKS