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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
11-28-2016, 09:53 AM
|
#1
|
Member
Registered: Dec 2011
Posts: 91
Rep: 
|
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.
|
|
|
11-28-2016, 10:02 AM
|
#2
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,494
|
Quote:
Originally Posted by azheruddin
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.
|
11-28-2016, 10:31 AM
|
#3
|
Member
Registered: Dec 2011
Posts: 91
Original Poster
Rep: 
|
Thanks, I have only FTP option available to continue.
how I an proceed further.
|
|
|
11-28-2016, 10:50 AM
|
#4
|
Moderator
Registered: Aug 2002
Posts: 26,552
|
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.
|
11-28-2016, 10:59 AM
|
#5
|
Member
Registered: Dec 2011
Posts: 91
Original Poster
Rep: 
|
Thank you very much, it has worked out.
thread considered to be resolved.
|
|
|
11-29-2016, 07:06 AM
|
#6
|
Member
Registered: Dec 2011
Posts: 91
Original Poster
Rep: 
|
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
|
|
|
11-29-2016, 07:34 AM
|
#7
|
Moderator
Registered: Aug 2002
Posts: 26,552
|
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.
|
|
|
12-01-2016, 10:24 AM
|
#8
|
Member
Registered: Dec 2011
Posts: 91
Original Poster
Rep: 
|
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
|
|
|
12-01-2016, 07:47 PM
|
#9
|
Member
Registered: Dec 2011
Posts: 91
Original Poster
Rep: 
|
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
|
|
|
12-02-2016, 01:46 AM
|
#10
|
Member
Registered: Dec 2011
Posts: 91
Original Poster
Rep: 
|
???
|
|
|
12-02-2016, 07:14 AM
|
#11
|
Senior Member
Registered: Dec 2011
Location: Simplicity
Distribution: Mint/MATE
Posts: 3,023
|
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 12:48 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|