# Python FTP login and relogin with other data in one wash?

**URL:** <https://community.unix.com/t/python-ftp-login-and-relogin-with-other-data-in-one-wash/334372>\
**Category:** Shell Programming and Scripting\
**Created:** [September 17, 2013, 7:51am UTC](https://community.unix.com/t/python-ftp-login-and-relogin-with-other-data-in-one-wash/334372 "2013-09-17T07:51:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lowmaster](https://community.unix.com/letter_avatar/lowmaster/32/6_22734026db12803ebb3e059622ac3534.png) [@lowmaster](https://community.unix.com/u/lowmaster)\
**Post date:** [September 17, 2013, 7:51am UTC](https://community.unix.com/t/python-ftp-login-and-relogin-with-other-data-in-one-wash/334372/1 "2013-09-17T07:51:54Z")

</div>

I have a short part of the script like this, which scrans ftp ips from a list and login with the data specified.

```nohighlight
login1
pssword1

```

is it possible to try sevral login data without starting the script again with modified login data?

somehow like:  
if (login1 pw1 or login2 pw2 or login3 pw3)  
{  
print "unsafe"  
}

```nohighlight
                    try:
                        ftp = ftplib.FTP(ip_add)
                        ftp.login('login1', 'password1') 
                    except ftplib.all_errors:
                        print 'OK: %s' % (ip_add)
                    else:
                        print 'Unsafe PW: %s' % (ip_add)
                        write = open('Ftp.txt', "a+")
                        write.write(ip_add + '\n')
                        write.close()  
                        ftp.quit()

```
