1

When I run the script it closes the terminal. I want to print and display a message and also to see that it has completed. Maybe a status bar?

import ftplib
from ftplib import FTP

ftp_add =  input('ftp address:')
username = input('username:')
password = input('password:')


ftp = FTP(ftp_add)
ftp.login(username, password)
ftp.retrlines('LIST')
ftp.cwd("/public_html")
file_list = []
filenames = ftp.nlst()


ftp.close() 
sameera lakshitha
  • 1,925
  • 4
  • 21
  • 29
johnashu
  • 2,167
  • 4
  • 19
  • 44
  • Add `input()` at the end if you want to keep the terminal open – OneCricketeer Apr 14 '17 at 03:12
  • Have you tried running it in an existing terminal window, so it sticks around after? – ShadowRanger Apr 14 '17 at 03:13
  • Did you want to maybe print the filenames? – OneCricketeer Apr 14 '17 at 03:14
  • i think im just trying to create a similar environment to an ftp program.. i want to elaborate and continue in the terminal if necessary.. im not sure if i understand python scripts corrrectly.. can i initiate a script but still leave the interpreter op[en to commancds.. commands which can still be related to the original script execute? – johnashu Apr 14 '17 at 03:19
  • i guess im building an ftp program from toddler level.. – johnashu Apr 14 '17 at 03:20
  • @shadowranger.. yes i do do that but i would rather run it as a program style rather than demand the command prompt – johnashu Apr 14 '17 at 03:27
  • 1
    If you execute a script, it does just that, opens the file and returns back. If you want an **interactive** session after the script, you use `python -i script.py`. http://stackoverflow.com/questions/1027714/how-to-execute-a-file-within-the-python-interpreter – OneCricketeer Apr 14 '17 at 03:34
  • i can confirm there's nothing wrong with your code, it gives me an ftp server site listing – chickity china chinese chicken Apr 14 '17 at 05:51
  • thanks.. i have worked it outnow.. it had a lot to do with how i was executing python lol.. I am moving onto secure ftp script!! – johnashu Apr 14 '17 at 14:45

0 Answers0