Results 1 to 2 of 2
Hello,
I am a newbie on linux so I hope somebody can help me.
I use ubuntu with apache2 and awstats as statisti server for our log files (IIS)
Some ...
- 01-09-2009 #1Just Joined!
- Join Date
- Jan 2009
- Posts
- 1
shell script problem
Hello,
I am a newbie on linux so I hope somebody can help me.
I use ubuntu with apache2 and awstats as statisti server for our log files (IIS)
Some of the log files (we have 7 sites) are very large (1 GB ore more) so I download them once a day.
I try to automate the process using lftp but i strugle.
Here is what I do in my script.
#! /bin/sh
set -v
USER=xxx
PASS=xxxxxx
FTPSERVER=x.x.x.x
LogFileName="ex`date --date='1 days ago' +%y%m%d%n`.log"
LogFileOld=ex`date --date='2 days ago' +%y%m%d%n`.log
File=/media/disk/var/LogFiles/IIS/W3SVC1/$LogFileOld
FileSize=$(stat -c%s "$File")
if [ $FileSize > 0 ]; then
lftp -u $USER,$PASS $FTPSERVER
set ftp
assive-mode off
pget -n 10 /W3SVC1/$LogFileName -o /media/disk/var/LogFiles/IIS/W3SVC1/ << EOF
get -E /W3SVC1267602825/$LogFileName -o /media/disk/var/LogFiles/IIS/W3SVC1267602825/ << EOF
get -E /W3SVC1381240666/$LogFileName -o /media/disk/var/LogFiles/IIS/W3SVC1381240666/ << EOF
get -E /W3SVC58705661/$LogFileName -o /media/disk/var/LogFiles/IIS/W3SVC58705661/ << EOF
get -E /W3SVC68712285/$LogFileName -o /media/disk/var/LogFiles/IIS/W3SVC68712285/ << EOF
get -E /W3SVC85267630/$LogFileName -o /media/disk/var/LogFiles/IIS/W3SVC85267630/ << EOF
get -E /W3SVC924016051/$LogFileName -o /media/disk/var/LogFiles/IIS/W3SVC924016051/ << EOF
!/home/ofm/
!sudo bash awupdate
exit;
else
lftp -u $USER,$PASS $FTPSERVER
set ftp
assive-mode off
pget -n 10 /W3SVC1/$LogFileName -o /media/disk/var/LogFiles/IIS/W3SVC1/ << EOF
get -E /W3SVC1267602825/$LogFileName -o /media/disk/var/LogFiles/IIS/W3SVC1267602825/ << EOF
get -E /W3SVC1381240666/$LogFileName -o /media/disk/var/LogFiles/IIS/W3SVC1381240666/ << EOF
get -E /W3SVC58705661/$LogFileName -o /media/disk/var/LogFiles/IIS/W3SVC58705661/ << EOF
get -E /W3SVC68712285/$LogFileName -o /media/disk/var/LogFiles/IIS/W3SVC68712285/ << EOF
get -E /W3SVC85267630/$LogFileName -o /media/disk/var/LogFiles/IIS/W3SVC85267630/ << EOF
get -E /W3SVC924016051/$LogFileName -o /media/disk/var/LogFiles/IIS/W3SVC924016051/ << EOF
rm /W3SVC1/$LogFileOld
!/home/ofm/
!sudo bash awupdate
exit;.
If I try to run the script I get a error message aboput a unexpected end of file
I also tried to put the lftp parts into a seperate file and call it from the script but if I do so the called script stops after the succsefull lftp login.
Thank you in advance
Oliver
- 01-10-2009 #2
So first off, in the future, please kindly wrap your code in [code] tags and indent. It makes it a lot easier to read.
As to the particular issue, it looks to me like you wanted to use here documents, but didn't. It also looks like you're mixing FTP and non-FTP commands.
So basically, running the lftp command opens up lftp. I suspect that you then want to pass the following commands into the running lftp process. You can do this by using here documents, explained here:
http://www.tldp.org/LDP/abs/html/here-docs.html
If you're going to do this, make sure that the commands you're passing in are valid input to lftp. I don't know the program, but I suspect that the GET command is just "get", and doesn't take any flags.
Hope this helps.DISTRO=Arch
Registered Linux User #388732


Reply With Quote