LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-25-2021, 11:53 AM   #1
lmu9@yahoo.com
LQ Newbie
 
Registered: Dec 2009
Posts: 3

Rep: Reputation: 0
Question check for a file then lftp a different file to a directory


This is for an Oracle E-business concurrent request. The request uses a file on the file system to lftp receipts to archive. It runs every 5 minutes to check for the file. If the file is not there, it should do nothing or say file is not there.

Process needs to check for 2 files, an *.ack file and an *.xml file in a directory. When the xml file is there, then move the ack file.

This code checks for a file, but i need to check for both files the *.ack file and *.xml file. When both are there move the ack file to archive.

if [ "$(ls -A $lclDirOut/*.*)" ]; then
echo "Files found in $lclDirOut"
cd $lclDirOut
chmod 777 *
lftp <<EOP
open $rserver
user $touser $topwd
echo "Copying files to Remote Server $vORacleFiles"
lcd $lclDirOut
mput *.*
bye
EOP
else
echo "No files found in $lclDirOut."
fi

Thank you for the help.
 
Old 02-25-2021, 12:09 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,702

Rep: Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972
Quote:
Originally Posted by lmu9@yahoo.com View Post
This is for an Oracle E-business concurrent request. The request uses a file on the file system to lftp receipts to archive. It runs every 5 minutes to check for the file. If the file is not there, it should do nothing or say file is not there.

Process needs to check for 2 files, an *.ack file and an *.xml file in a directory. When the xml file is there, then move the ack file. This code checks for a file, but i need to check for both files the *.ack file and *.xml file. When both are there move the ack file to archive.
Code:
if [ "$(ls -A $lclDirOut/*.*)" ]; then
echo "Files found in $lclDirOut"
cd $lclDirOut
chmod 777 *
lftp <<EOP
open $rserver
user $touser $topwd
echo "Copying files to Remote Server $vORacleFiles"
lcd $lclDirOut
mput *.*
bye
EOP
else
echo "No files found in $lclDirOut."
fi
Thank you for the help.
You should repost your code in CODE tags so the formatting is kept. And you may also want to tell us what your actual problem/issue IS, rather than just what you want to accomplish. You've not given us any details about the version/distro of Linux you're running either...not alot we can help with when we don't have details or a clear question.

::EDIT::
You've been a member here for twelve years, and haven't followed up in either of your previous threads.

Last edited by TB0ne; 02-25-2021 at 12:11 PM.
 
Old 02-25-2021, 12:11 PM   #3
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206
Quote:
Originally Posted by lmu9@yahoo.com View Post
This code checks for a file, but i need to check for both files the *.ack file and *.xml file.
Please wrap your code snippets in [CODE]...[/CODE] tags to preserve formatting and help to make it easier for others to read it. You may type those yourself or follow the Advanced edit option and click the # tool button at top of the edit box.

You did not actually ask a question, but instead seem to be asking for someone to write the code for you. If so, this is probably not the right place for tech support.

That said, you have described your objective and have an example script which performs one of two similar tests, have you tried to implement the second test yourself? If so, please show what you have done and tell us what problem you are having with it, and someone will be happy to help you sort it out.

Please review the LQ FAQ, particularly the linked article How to ask a question, for guidance in forum usage. Remember the more effort you put into asking your questions, the better the response will be!
 
  


Reply



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
lftp no empty directory options does not work ra93013 Linux - Software 0 01-13-2015 09:48 PM
lftp mirror: Access failed: 550 /var/www/vhosts/test: No such file or directory speedy6 Linux - Software 11 10-22-2012 02:06 PM
Get first file of directory then copy to other directory andd rename the file Faye Linux - Software 4 01-30-2011 09:16 AM
if file *.txt then do x else if *.mp3 file then do xx (bash) Techno Guy Linux - Newbie 3 04-12-2009 08:52 PM
lftp different local port? sycamorex Linux - Networking 1 05-06-2008 11:31 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:17 AM.

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
Open Source Consulting | Domain Registration