LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-28-2016, 09:53 AM   #1
azheruddin
Member
 
Registered: Dec 2011
Posts: 77
Blog Entries: 1

Rep: Reputation: Disabled
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.

Last edited by azheruddin; 11-28-2016 at 09:57 AM.
 
Old 11-28-2016, 10:02 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,960

Rep: Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693
Quote:
Originally Posted by azheruddin View Post
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...
 
1 members found this post helpful.
Old 11-28-2016, 10:31 AM   #3
azheruddin
Member
 
Registered: Dec 2011
Posts: 77
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
Thanks, I have only FTP option available to continue.

how I an proceed further.
 
Old 11-28-2016, 10:50 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 14,963

Rep: Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530
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

Last edited by michaelk; 11-28-2016 at 10:54 AM.
 
1 members found this post helpful.
Old 11-28-2016, 10:59 AM   #5
azheruddin
Member
 
Registered: Dec 2011
Posts: 77
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
Thumbs up

Thank you very much, it has worked out.
thread considered to be resolved.
 
Old 11-29-2016, 07:06 AM   #6
azheruddin
Member
 
Registered: Dec 2011
Posts: 77
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
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
 
Old 11-29-2016, 07:34 AM   #7
michaelk
Moderator
 
Registered: Aug 2002
Posts: 14,963

Rep: Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530
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.
 
Old 12-01-2016, 10:24 AM   #8
azheruddin
Member
 
Registered: Dec 2011
Posts: 77
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
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
 
Old 12-01-2016, 07:47 PM   #9
azheruddin
Member
 
Registered: Dec 2011
Posts: 77
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
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 
 
Old 12-02-2016, 01:46 AM   #10
azheruddin
Member
 
Registered: Dec 2011
Posts: 77
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
???
 
Old 12-02-2016, 07:14 AM   #11
MadeInGermany
Member
 
Registered: Dec 2011
Posts: 200

Rep: Reputation: 78
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
yum working fine on server and ftp is working f9 but not able to config yum on client joj123 Red Hat 12 01-13-2015 07:03 PM
not able to ftp from aix to aix server manoj.linux AIX 3 09-05-2008 01:15 AM
line count mismatch between AIX and Linux after ftp cool244 AIX 7 03-15-2005 11:22 AM
SED command doesn't works fine on AIX JSnake AIX 4 07-01-2004 01:32 PM


All times are GMT -5. The time now is 04:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration