Hi pals,
I have a wriiten a shell script which is connects to remote server and get some selected
files.In my present working directory, i have the following 6 files. Out of 6 files , i
need to copy only 4 excluding the file(s) containing "tar" as part of the filename.
$pwd
/home/manu
$ls -1 req_*
req_detail_QAU.dat
req_detail_SAM.dat
req_detail_SJC.dat
req_detail_TAM.dat
req_detail_tAr.dat
HI pals,
I need some help
I need to copy those file other than "req_detail_tAr.dat" & "req_detail_TAR.dat".
i.e i need to get only 4 files. out of above four.
vi test
TEST()
{
ftp -n -v -i <<-EOF
open 192.168.1.139
user maheshv choice#123
lcd $HOME/[00000.SCORE]/
mget < (ls -1 req_detail*|grep -iv "tar")
bye
EOF
}
TEST
$
But it is copying all the files. Basically what is happening is mget is taking input
from (ls -1 req_detail) but not ("ls -1 req_detail*|grep -iv "tar").
But why it is behaving like this.
Any comments will be appreciable.
Thanks in advance.
Manu
aigles
January 26, 2007, 8:48am
2
What is your Unix flavor ?
On my AIX box, ftp doesn't support the syntax 'mget < ...'
Jean-Pierre.
ftp doesn't support full shell syntax.
execute a remote shell command first, to list the files, then ftp them.
Aigles - mget is multiple get - a 'globbed' get, with the ftp -i option
echo "
open somenode
username password
cd /directory
lcd /another_directory
bin
mget *.lis
bye " | ftp -i -n > ftp.log
gets all files the end with .lis
aigles
January 26, 2007, 2:13pm
4
I know the mget command, but not the syntax used by Manu.
Error or Unix flavour specific syntax ?
Jean-Pierre.
Error - ftp doesn't support redirection or subprocess creation on the mget command line.
Some versions of ftp support ! -- escape to shell
ftp
ftp> ! ls *.lis
addr.lis big_prem.lis rr.lis sb.lis t.lis tou.lis ubtibil.lis uzpb.lis y.lis
bad_cust.lis cust.lis rr195.lis src.lis t1.lis tusc.lis ucrasvh.lis uzpsocl.lis z.lis
badprem.lis prem.lis rr_wnd1.lis srch.lis t2.lis ubr.lis urrshis.lis uzrebpp.lis zma.lis
big_cust.lis rperint.lis s.lis sum.lis test1.lis ubracex.lis uzebpux.lis wn2.lis
ftp>bye
aigles
January 27, 2007, 12:52pm
7
A possible solution (not tested) :
TEST()
{
#
# Get file list
#
ftp -n -v -i <<-EOF
open 192.168.1.139
user maheshv choice#123
lcd $HOME/[00000.SCORE]/
ls . /tmp/file_list.dat
bye
EOF
#
# Build ftp script
#
cat <<-EOF > /tmp/ftp.sh
open 192.168.1.139
user maheshv choice#123
lcd $HOME/[00000.SCORE]/
EOF
awk '/^req_detail/ && ! /tar/ {
print get $0
} /tmp/file_list.dat >> /tmp/ftp.sh
#
# Get files
#
sh /tmp/ftp.sh
}
Jean-Pierre.