Sponsored Content
Top Forums UNIX for Dummies Questions & Answers If then else in with mget command Post 302501035 by zaxxon on Wednesday 2nd of March 2011 10:02:56 AM
Old 03-02-2011
You did not tell anything about the other suggestions like using scp instead of sftp, but yes, you can do this, but the problem will be, that every output your sftp client produces, will be caught in that variable.
A more clean solution would be using ssh/scp.

Example (adjust your shell and <user> <host> etc. of course!):
Code:
#!/bin/bash

echo "Starting.. -" $(date)

# get list:
echo "Getting file list ..."
FILELIST="$(ssh -o "ConnectTimeout=3" -o "BatchMode yes" <user>@<host> ls -1 /directory/${JOURNAL_CODE}*_[1-2]_Audit*.txt)"

# if $FILELIST not empty, then get files:
if [ -n $FILELIST ]; then
   for file in $FILELIST; do
      echo "Getting file $file ..."
      scp <user>@<host>:/directory/$file /localdestdir
   done
else
   echo "Sorry, nothing there."
fi

echo "This is the End -" $(date)
echo "--------------------------------------"

exit 0

Untested, maybe some slight modifications needed.

Last edited by zaxxon; 03-02-2011 at 11:16 AM.. Reason: added things in case it should be automated and written to a log via cron or what do I know ;)
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

mget (ftp command)

hey, I was wondering if its possible to use a complete path and file name using the mget command example mget /dir1/dir2/dir3/file.ext or get /dir1/dir2/dir3/file.ext because whenever i try its says file not found or permission denied..... but if i do cd dir1 cd dir2 cd dir3 mget... (2 Replies)
Discussion started by: Ganondorf
2 Replies

2. UNIX for Dummies Questions & Answers

mget

hi, i want to mget a directory. how to specify the flag that i dont want the system to prompt me? thanks (2 Replies)
Discussion started by: yls177
2 Replies

3. Shell Programming and Scripting

Is there a limit to mget command?

Hi All, I am using a csh ftp to get all the relevant files i need. When i reduce the number of file to 4 (which is aaa,bbb,ccc,ddd), the script manage to get all the files i need. But when i add "eee" to the mget command, it doesn;t seem to get any files at all. Is there a limit to how many... (0 Replies)
Discussion started by: Raynon
0 Replies

4. Shell Programming and Scripting

mget command

Hi All, I am using mget (mget server.*) through ftp... ... i dont want to overwrite the files in my localmachine if it is already exists... is it possible through ftp ?? any other optios also mos t welcome Thnks in advance (4 Replies)
Discussion started by: scorpio
4 Replies

5. UNIX for Advanced & Expert Users

mget ftp command options

Hi, I am using mget ftp command to pull a bunch of zip files from Windows to local unix machines. It is working fine as follows. -rw------- 1 autosys autosys 614 Aug 19 13:13 02034128.zip -rw------- 1 autosys autosys 1866 Aug 19 13:13 02034127.zip -rw------- 1 autosys autosys 14592 Aug 19... (1 Reply)
Discussion started by: spatra
1 Replies

6. Shell Programming and Scripting

mget ftp command options

Hi, I am using mget ftp command to pull a bunch of zip files from Windows to local unix machines. It is working fine as follows. -rw------- 1 autosys autosys 614 Aug 19 13:13 02034128.zip -rw------- 1 autosys autosys 1866 Aug 19 13:13 02034127.zip -rw------- 1 autosys ... (1 Reply)
Discussion started by: spatra
1 Replies

7. UNIX for Dummies Questions & Answers

mget command issues

Hi I am trying to get 3 files sitting on a FTP server to an application server. All 3 files are .csv files. I am using mget *.csv and it transfers only 2 files. the 3 files contain a common word in their file names "Report". I tried mget *Report*.csv and that gets me 2 files as well. ... (3 Replies)
Discussion started by: bobsn
3 Replies

8. Shell Programming and Scripting

Unix Mget command issue

Hi, I am facing an issue with mget command, below are the details The following commands are in a batch file "abc.ctl" cd /mypath/mydirectory/ mget 'MYFILE_*.touch' bye I use this file as a parameter for an sftp command sftp -b abc.ctl -oIdentityFile=$myserver -oPort=$myport >>... (0 Replies)
Discussion started by: saurabh_mh
0 Replies

9. UNIX for Dummies Questions & Answers

mget help

Hi I'm trying to get all files from a directory with a script. So i'm gone paste my script here: cd /var/www/match_demos/speedgaming/ lftp -u Gudfaren,xxxxx ftp.speedgaming.pro -e cd 89.221.243.11_27500 -e mget *.dem exit when i run that i get: "File name missed. Try `help mget' for more... (2 Replies)
Discussion started by: vYN
2 Replies

10. Shell Programming and Scripting

How to specify more then one pattern in a single mget statement of ftp command?

hi, i am using ftp command to get some files from a remote server. if the remote server contains files of different extension. abc.txt def.txt ghi.lst jkl.cnf is it possible to get all the three type of files in one ftp? i am using this ftp command $FTP $Remote_server <<_FTP1 ... (4 Replies)
Discussion started by: Little
4 Replies
ECACCESS-FILE-MPUT(1p)					User Contributed Perl Documentation				    ECACCESS-FILE-MPUT(1p)

NAME
ecaccess-file-mput - Upload Multiple Local Files on the ECaccess File System at once SYNOPSIS
ecaccess-file-mput -version|-help|-manual ecaccess-file-mput [-debug] [-progress] [-force] [-umask mode] [-bufsize length] source-local-file [...] target-ecaccess-directory DESCRIPTION
Allow uploading Multiple Local Files on target-ecaccess-directory at once. The target-ecaccess-directory is in the form [domain:][/user-id/]path. Please read the "Shell commands -> File Management" section of the "ecaccess" guide for more information on the ECaccess File System. Please note this command is not recursive and will only upload plain-files (directories specified as source-ecaccess-file are ignored). ARGUMENTS
source-local-file [...] The name(s) of the source File(s). target-ecaccess-directory The name of the target ECaccess Directory. OPTIONS
-progress Provide a progress meter on the standard terminal, allowing to monitor the file transmission in real-time. The progress bar is removed from the terminal when the transmission is done. This option is not supported and ignored on Windows platforms. -force Overrides the interactive mode and upload each file without prompting. -umask mode The user file-creation mode mask (umask) is used to determine the file permission for newly created files. The default value is 640. -bufsize length Specify the length of the buffer (in bytes) which is used to upload the files. The larger the buffer the smaller the number of http/s requests. By default a buffer of 10485760 bytes(10MB) is used. -version Display version number and exits. -help Print a brief help message and exits. -manual Prints the manual page and exits. -debug Display the SOAP messages exchanged. EXAMPLES
ecaccess-file-mput $HOME/*.txt home:/xyz/ Upload the local $HOME/*.txt Files in the ECaccess $HOME directory of the user xyz. SEE ALSO
ecaccess-file-delete, ecaccess-file-get, ecaccess-file-mget, ecaccess-file-modtime, ecaccess-file-chmod, ecaccess-file-rmdir, ecaccess- file-copy, ecaccess-file-dir, ecaccess-file-mdelete, ecaccess-file-mkdir, ecaccess-file-move, ecaccess-file-put, ecaccess-file-size and ecaccess. perl v5.14.2 2012-04-16 ECACCESS-FILE-MPUT(1p)
All times are GMT -4. The time now is 01:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy