English 中文(简体)
供暖、通风和取暖
原标题:SHELL script to make ftp connection and get xml files

I need a shell script that will login to a remote FTP server, get the list of files present in only root folder and identify only xml files and get those files to local system. Login credentials can be mentioned in the script it self. This script must be run once a day only.

请用UNIX BASH SHELL的文字帮助我。

增 编

问题回答

文字:

#!/bin/bash
SERVER=ftp://myserver
USER=user
PASS=password
EXT=xml
DESTDIR=/destinationdir

listOfFiles=$(curl $SERVER --user $USER:$PASS 2> /dev/null | awk  { print $9 }  | grep -E "*.$EXT$")
for file in $listOfFiles
do
   curl $SERVER/$file --user $USER:$PASS -o $DESTDIR/$file
done

a. 检查 cr:

crontab -e

for edit your current jobs and add for example:

0 0 * * * bash /path/to/script

that will mean run the script every day at midnight.

If you can install ncftpget, this is a one-line operation:

ncftpget -u user -p password ftp.remote-host.com /my/local/dir  /*.xml 




相关问题
KornShell- Creating a fixed width text file

I need to create a simple fixed width text file in KornShell (ksh). My current attempt using printf to pad the string isn t working out very well. What s the shortest, cleanest way to create a fixed ...

unix find command

how to use the find command to find files/directories which are not matching the pattern. for eg: find <some options > -name "dontfile.txt" should give me output of all the find whose file ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

Case insensitive comparison of strings in shell script

The == operator is used to compare two strings in shell script. However, I want to compare two strings ignoring case, how can it be done? Is there any standard command for this?

1. 露台式照像

在Windows XP中,没有一时出现指挥时,是否有办法操作一种灰色文字? 我常常需要把“善待”(工作)与“灰色”同起来,即使我的文字没有产出,......

热门标签