LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-17-2014, 03:34 PM   #1
fgcoppola
LQ Newbie
 
Registered: Dec 2012
Posts: 7

Rep: Reputation: Disabled
lftp - perform task only if connect successful


I have an lftp script that runs from cron. But I only want mv of files to take place if the connect is successful. So did the mv within the lftp script but the mv takes place even if the login fails. How can I conditionally mv the files ? Here is my script:
lftp -u user,pw -e 'set xfer:clobber yes;
cd /uploads;
lcd /commerce/ediexport;
!mv *.* /commerce/ediftpoutwork;
lcd /commerce/ediftpoutwork;
mput *.*;
!mv *.* /commerce/edioutarchive;
quit;' ip_address
exit

Thanks in advance for any help.
 
Old 05-18-2014, 03:21 PM   #2
fgcoppola
LQ Newbie
 
Registered: Dec 2012
Posts: 7

Original Poster
Rep: Reputation: Disabled
I revised the script this seems to do what I wanted:
#!/bin/bash
# An error exit function

function error_exit
{
echo "$1" 1>&2
exit 1
}

cd /commerce/ediexport
mv *.* /commerce/ediftpoutwork || error_exit "No files in ediexport"
lftp -u user,password -e 'set xfer:clobber yes;
cd /uploads;
lcd /commerce/ediftpoutwork;
mput *.* || exit 124;
!mv *.* /commerce/edioutarchive;
exit 120 ;' 63.90.115.213
STATUS="$?"
echo $STATUS
if [ "$STATUS" = "124" ]; then
echo "files put back to export"
mv /commerce/ediftpoutwork/*.* /commerce/ediexport

fi
exit
 
  


Reply

Tags
lftp


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending email after successful lftp mget or mirror chickenshit Linux - Software 1 10-03-2013 06:02 PM
[SOLVED] How to perform var++ task in shell script? antriksh Linux - Newbie 5 01-15-2013 12:51 AM
My ubuntu 10.04 restarts as i perform a certain task adam.athumani Linux - Newbie 1 08-24-2010 07:54 PM
script doesn't perform the same as task done by hand bradvan Linux - Server 2 03-31-2009 10:00 AM


All times are GMT -5. The time now is 02:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration