LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   FTP working fine in AIX but not in Linux (https://www.linuxquestions.org/questions/linux-newbie-8/ftp-working-fine-in-aix-but-not-in-linux-4175594366/)

azheruddin 11-28-2016 08:53 AM

FTP working fine in AIX but not in Linux
 
Hi All

I have a script to download the file from the remote FTP server , as we recently migrated from AIX to linux server.

Below is the exact same script code using in both machine
Code:

HOST='ftp1.sep.com'
USER='gp'
PASSWD='Password@123'
ftp $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
prompt
lcd /home/test/
mget *.nvp
mdel *.nvp
quit
END_SCRIPT
exit 0


AIX successful output

PHP Code:

sys01~> /home/test/get_gp.sh
Interactive mode off
.
Local directory now
can
't find list of remote files, oops 

Linux unsuccessful login outpur
PHP Code:

sys01~> /home/test/get_gp.sh
Password
:Name (ftp1.malaysia-airlines.com:sys01):
Not logged in.
Login failed.
Bad sequence of commands.
Interactive mode off.
Local directory now /home/fisdata
Not logged in
.
Passive mode refused.
Passive mode refused.
Not connected.
Not connected

issue seems it is taking script considering server level login id instead of which is defined in the FTP script, pelase advise how to rectify

Thanks.

TB0ne 11-28-2016 09:02 AM

Quote:

Originally Posted by azheruddin (Post 5635376)
Hi All
I have a script to download the file from the remote FTP server , as we recently migrated from AIX to linux server. Below is the exact same script code using in both machine
Code:

HOST='ftp1.sep.com'
USER='gp'
PASSWD='Password@123'
ftp $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
prompt
lcd /home/test/
mget *.nvp
mdel *.nvp
quit
END_SCRIPT
exit 0

AIX successful output
PHP Code:

sys01~> /home/test/get_gp.sh
Interactive mode off
.
Local directory now
can
't find list of remote files, oops 

Linux unsuccessful login outpur
PHP Code:

sys01~> /home/test/get_gp.sh
fismgr
@MASG-3IFMSDB-LX:/var/run> /home/fismgr/fisbin/get_mhfy.sh
Password
:Name (ftp1.malaysia-airlines.com:sys01):
Not logged in.
Login failed.
Bad sequence of commands.
Interactive mode off.
Local directory now /home/fisdata
Not logged in
.
Passive mode refused.
Passive mode refused.
Not connected

issue seems it is taking script considering server level login id instead of which is defined in the FTP script, pelase advise how to rectify

Re-write your script. Either the FTP client you're using doesn't support using "QUOTE", or there is another issue. You don't say what the remote server is running, or what your local machine is running, only that you're going from AIX to Linux, and don't tell us what's running where, or what version(s) of things you're using.

"Expect" is typically used for such scripts, and there are plentiful examples:
http://www.linuxquestions.org/questi...upload-677298/

However, I'd *STRONGLY* suggest you not use such things, but use SFTP/SCP to transfer files, by doing a key-swap between the machines. MUCH more secure...

azheruddin 11-28-2016 09:31 AM

Thanks, I have only FTP option available to continue.

how I an proceed further.

michaelk 11-28-2016 09:50 AM

As suggested you need to rewrite your script. Here is a way to login similar to how you do it in AIX. The -n option prevents ftp from attempting to auto-login.
Code:

#!/bin/bash

myuser="myuser"
mypass="mypassword"
host="myhost"
ftp -nvi $host <<END_SCRIPT
user $myuser $mypass
.. rest of your commands go here
quit
END_SCRIPT


azheruddin 11-28-2016 09:59 AM

Thank you very much, it has worked out.
thread considered to be resolved.

azheruddin 11-29-2016 06:06 AM

Hi,
in below script how i can write a command to delete files older then 15 days, i know mdel will use to delete files but older than 15 days deletion command please?

Code:

HOST='ftp1.sep.com'
USER='gp'
PASSWD='Password@123'
ftp $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
prompt
lcd /home/test/
mget *.nvp
mdel *.nvp
quit
END_SCRIPT
exit 0


michaelk 11-29-2016 06:34 AM

There isn't a simple command to delete files older then x days using ftp. You can find sever similar scripts like the one below if you google. No idea how well it works.

http://stackoverflow.com/questions/1...files-from-ftp

Another option would be to install curlftpfs. It is a ftp fuse filesystem. You could then write a script to use linux tools like find to delete the desired files.

azheruddin 12-01-2016 09:24 AM

Hi ,

seems in my code '\' is ignoring in user id and considering DB_SVCGPRUAT as a ID and failing to connect to the FTP server. my complete ID 'BD\SVCGPRUAT', how to rectify this error.

Code:

#!/bin/bash

myuser='"BD\_SVCGPRUAT"  { BD is domain }
mypass='Welcome$123'
host="10.230.120.55"
ftp -nvi $host <<END_SCRIPT


Connected to 10.230.120.55 (10.230.120.55).
220 Microsoft FTP Service
331 Password required for DB_SVCGPRUAT.
530 User MH_SVCGPRUAT cannot log in.
Login failed.
Interactive mode on.
?Invalid command
221

azheruddin 12-01-2016 06:47 PM

Hi ,

seems in my code '\' is ignoring in user id and considering DB_SVCGPRUAT as a ID and failing to connect to the FTP server. my complete ID 'BD\SVCGPRUAT', how to rectify this error.
Code:

#!/bin/bash

myuser='"BD\_SVCGPRUAT"  { BD is domain }
mypass='Welcome$123'
host="10.230.120.55"
ftp -nvi $host <<END_SCRIPT

Error:
PHP Code:

Connected to 10.230.120.55 (10.230.120.55).
220 Microsoft FTP Service
331 Password required 
for BD_SVCGPRUAT.
530 User MH_SVCGPRUAT cannot log in.
Login failed.
Interactive mode on.
?
Invalid command
221 


azheruddin 12-02-2016 12:46 AM

???

MadeInGermany 12-02-2016 06:14 AM

To preserve a literal \ or $ in shell, have it in 'ticks'
Code:

myuser='BD\_SVCGPRUAT'
mypass='Welcome$my$friend'
# Test the variable substitution in a << here document
cat << END_SCRIPT
login $myuser
pw $mypass
END_SCRIPT



All times are GMT -5. The time now is 03:56 AM.