I am having a script which pulls data from different servers whose details it reads from external file. It reads the files and the verbose output shows all the matching files but it fetches only one file from the remote host. Following is my script:while IFS=','; read region sdp ip1 ip2 ip3 user1 pass1 user2 pass2 user3 pass3do    in=/var/opt/fds/statistics/    out=/pmautomation/PM/RawFiles/Data/BHCA/$date/$region/$sdp/    file=\*PSC-TrafficHandler_8.1_A_\*_System.$date\*.stat    mkdir -p /pmautomation/PM/RawFiles/Data/BHCA/$date/$region/$sdp/    ftp -in $ip1<<END_SCRIPT    quote USER $user1    quote PASS $pass1    bin    prompt off    lcd /pmautomation/PM/RawFiles/Data/BHCA/$date/$region/$sdp/    cd /var/opt/fds/statistics/    binary    mget *PSC-TrafficHandler_8.1_A_*_System.$date*.stat    bye    END_SCRIPTdone < /root/SDP_BHC/bin/Credentials.csvFollowing is the output:IP: 10.XXX.XX.XXInteractive mode on.Local directory now /pmautomation/PM/RawFiles/Data/BHCA/20150802/EAST/WB_SDP49mget WDSDP49B_PSC-TrafficHandler_8.1_A_2_System.20150802_0000.stat? mget WDSDP49B_PSC-TrafficHandler_8.1_A_2_System.20150802_0100.stat? mget WDSDP49B_PSC-TrafficHandler_8.1_A_2_System.20150802_0200.stat? mget WDSDP49B_PSC-TrafficHandler_8.1_A_2_System.20150802_0300.stat? mget WDSDP49B_PSC-TrafficHandler_8.1_A_2_System.20150802_0400.stat? mget WDSDP49B_PSC-TrafficHandler_8.1_A_2_System.20150802_0500.stat? mget WDSDP49B_PSC-TrafficHandler_8.1_A_2_System.20150802_0600.stat? mget WDSDP49B_PSC-TrafficHandler_8.1_A_2_System.20150802_0700.stat? mget WDSDP49B_PSC-TrafficHandler_8.1_A_2_System.20150802_0800.stat? mget WDSDP49B_PSC-TrafficHandler_8.1_A_2_System.20150802_0900.stat? mget WDSDP49B_PSC-TrafficHandler_8.1_A_2_System.20150802_1000.stat? mget WDSDP49B_PSC-TrafficHandler_8.1_A_2_System.20150802_1100.stat? mget WDSDP49B_PSC-TrafficHandler_8.1_A_2_System.20150802_1200.stat? mget WDSDP49B_PSC-TrafficHandler_8.1_A_2_System.20150802_1300.stat? mget WDSDP49B_PSC-TrafficHandler_8.1_A_2_System.20150802_1400.stat? mget WDSDP49B_PSC-TrafficHandler_8.1_A_2_System.20150802_1500.stat? mget WDSDP49B_PSC-TrafficHandler_8.1_A_2_System.20150802_1600.stat? mget WDSDP49B_PSC-TrafficHandler_8.1_A_2_System.20150802_1700.stat? mget WDSDP49B_PSC-TrafficHandler_8.1_A_2_System.20150802_1800.stat? mget WDSDP49B_PSC-TrafficHandler_8.1_A_2_System.20150802_1900.stat? mget WDSDP49B_PSC-TrafficHandler_8.1_A_2_System.20150802_2000.stat? mget WDSDP49B_PSC-TrafficHandler_8.1_A_2_System.20150802_2100.stat? mget WDSDP49B_PSC-TrafficHandler_8.1_A_2_System.20150802_2200.stat? mget WDSDP49B_PSC-TrafficHandler_8.1_A_2_System.20150802_2300.stat? Why my mget command is not able to get all the files and getting only one file from all the matching files?
Why won't my FTP script get all the files using mget command?
shell script;ftp
I have got some pointers from Jeff. Somehow the prompt off was not working and i was getting prompt to get the matching files. I have tried putting the 'y' below the mget command and it worked. Following is the updated code:while IFS=','; read region sdp ip1 ip2 ip3 user1 pass1 user2 pass2 user3 pass3do    in=/var/opt/fds/statistics/    out=/pmautomation/PM/RawFiles/Data/BHCA/$date/$region/$sdp/    file=\*PSC-TrafficHandler_8.1_A_\*_System.$date\*.stat    mkdir -p /pmautomation/PM/RawFiles/Data/BHCA/$date/$region/$sdp/    ftp -in $ip1<<END_SCRIPT    quote USER $user1    quote PASS $pass1    bin    prompt off    lcd /pmautomation/PM/RawFiles/Data/BHCA/$date/$region/$sdp/    cd /var/opt/fds/statistics/    binary    mget *PSC-TrafficHandler_8.1_A_*_System.$date*.stat    y    y    y    y    bye    END_SCRIPTdone < /root/SDP_BHC/bin/Credentials.csvThis is really strange behavior but it worked for me. Luckily i knew the number of files in remote host and putting the same number of 'y' made it work.