FTP Login Error check


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting FTP Login Error check
# 8  
Old 02-23-2012
I concur that the return code from ftp is still zero when the login failed.

For automated ftp scripts you would normally use a $HOME/.netrc file (owned by root and with permissions 600) containing the servername username and password. You still need some error handling in case the remote end password changes.

Your ftp script suggests to me that you are already using a .netrc file, or perhaps you are trying to force the user to enter the password?

The above was just in case you didn't know about .netrc files.



The main remaining use for ftp nowadays is to transfer files between incompatible older systems or where free software is important. Your script suggests that both systems are modern unix in which case we would normally use a modern file transfer method.

Does the script actually work? I can't see how the "*" in the breakout "!" line gets expanded. There is much variation in unix and ftp and IBM never cease to amaze me with their variations.
# 9  
Old 02-24-2012
mrn6430, if you were to solve a problem and the computer responded after entering a command the following error message
Code:
this did not do anything

would you be able to solve this? So, please give a detailed error output you got when using the here-script corona presented. Help us to help yourself, thanks.
# 10  
Old 02-24-2012
Further to zaxxon it would be helpful to show where the ftp username and password are coming from. Please blot any real values with X's .
# 11  
Old 02-24-2012
In all cases ftp will always return zero unless it cant ftp at all that means run itself...).
So you are doomed if looking for simple test...
Most people use dummy files put/get with CRC to check...
Code:
220 lo17 FTP server (Version 4.2 Mon Sep 21 10:03:34 CDT 2009) ready.
Name (lo17:vbe): titi
331 Password required for titi.
Password:
530 Login incorrect.
Login failed.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> 221 Goodbye.
ant:/home/vbe $ echo $?
0

That 221 goodbye was the result of a CTRL-d....
# 12  
Old 02-24-2012
Here is my Own design and it does work: "I was hoping of an easier way!!!!".
Code:
ftp $HOST1 <<END_SCRIPT>EpicFtp.chk
cd idx
prompt
mget $PICKUPFILE*.txt
!cp $PICKUPFILE* $TARGETPATH/data/
bye
END_SCRIPT
exit 0
 
ErrorChk=`grep "Login incorrect" EpicFtp.chk| wc -l'`
 
if [ $ErrorChk -gt 0 ]
then
 echo "FtpFromEpicFileIn.sh:Unable to login to Epic Production server. Check jcaps Id/Password."|mailx -s "Prod Epic To Idx Charges Login Error" $PageOncall
fi


Last edited by methyl; 02-24-2012 at 05:34 PM.. Reason: please use code tags
# 13  
Old 02-24-2012
Just for completeness, how are you giving the ftp process the login name and password? Is it from the keyboard of from a .netrc file or from "expect"? There is no "user" line in your ftp script so it can't be that way.

For a tight script you'll need to also check the exit status (a poster earlier showed how) and check for more different error messages. Once you have one robust script it becomes easy to either clone it or turn it into a utility.
# 14  
Old 02-24-2012
Well, there's doubtless simpler ways than counting the number of lines output from grep in backticks to find whether grep found your string... grep's own return value, perhaps?


Code:
if grep "Login incorrect" EpicFtp.chk > /dev/null
then
        echo "FtpFromEpicFileIn.sh:Unable to login to Epic Production server. Check jcaps Id/Password."|mailx -s "Prod Epic To Idx Charges Login Error" $PageOncall
fi

That only covers one kind of error, though. 'connection refused' or something might not be detected.
This User Gave Thanks to Corona688 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

FTP log only shows FTP LOGIN FROM entry?

OS: Solaris 9 Configuration /etc/syslog.conf daemon.debug /etc/inetd.conf ftp stream tcp6 nowait root /usr/sbin/in.ftpd in.ftpd -A -l -d Found the ftp.log only generate those entries from other servers/hosts. Can we trace on all ftp entries either from/to the server? ... (6 Replies)
Discussion started by: KhawHL
6 Replies

2. Cybersecurity

Check login detail

As a root user i switch to a different user say "oratest". I would like to know the details like at what time did the switch ( su - oratest ) happen. Are there any logs to check this Thanks. (2 Replies)
Discussion started by: jjoy
2 Replies

3. UNIX for Dummies Questions & Answers

Check login details

As a root user i switch to a different user say "oratest". I would like to know the details like at what time did the switch ( su - oratest ) happen. Are there any logs to check this Thanks. (4 Replies)
Discussion started by: jjoy
4 Replies

4. Solaris

error message rmclomv ... SC Login Failure for user Please login:

Hello World ~ HW : SUN Fire V240 OS : Solaris 8 Error message prompts 'rmclomv ... SC login failure ...' on terminal. and Error Message prompts continually 'SC Login Failure for user Please login:' on Single Mode(init S) The System is in normal operation, though In case of rain, Can... (1 Reply)
Discussion started by: lifegeek
1 Replies

5. Solaris

Check systems login

Hi All, In Solaris 10, how can I check back who is login to the systems by telnet, ssh and ftp in success or failed. I already check on /var/adm/messages but no details for all this. Hope your can help. Thanks. (1 Reply)
Discussion started by: mailbox80
1 Replies

6. UNIX for Advanced & Expert Users

Using FTP to check whether file is completely FTP... plz find the description below

Hi, We have some clients who will place huge files in to one of the remote server. And the shell script written in our local server to retrieve client files (using FTP) placed on one of the remote server of ours by clients. My question Is there any FTP command/script to check from my local... (1 Reply)
Discussion started by: nmsrao
1 Replies

7. UNIX for Advanced & Expert Users

Check existence of a login

Hi everybody, I need to check in C program wether a given login is known on the system. Is there any system function that could do this ? So far, all I could find is getpwnam(), which answers my problem by parsing the local password database. But won't work if a user is authenticated by... (10 Replies)
Discussion started by: xavier054
10 Replies

8. UNIX for Advanced & Expert Users

FTP login problem

I've just configured a server to my network (setting the ip, netmask, host file, etc...) and the server doesn't have any problem pinging another computer on the network. however when i try to connect to the server via ftp the root account can't log in, i made another account (a standard one that... (2 Replies)
Discussion started by: pasalagua
2 Replies

9. UNIX for Dummies Questions & Answers

Automated FTP to variable directory with error check

Hi, automated FTP that have error check and each product FTP will used the same userid/password to post(transfer) the file(s) from their <product> directory at UNIX to their <product> folder at Windows. such senarios as follows: NOTE: ======= ** Variable ** * The <product> is variable... (3 Replies)
Discussion started by: songtam
3 Replies

10. UNIX for Dummies Questions & Answers

FTP login failing

Please help. I am running Solaris 8 trying to get my FTP to work. When I try to access the FTP server from another computer on the network, it connects and prompts for a password. The username and password I set up do not work as well as my root account. Neither of the accounts are set up in the... (3 Replies)
Discussion started by: zbis12
3 Replies
Login or Register to Ask a Question