Python : Using Pexpect: ftpTest.py

#!/usr/bin/python # Connects to a public ftp server, downloads a file import pexpect import sys child = pexpect.spawn(‘ftp ftp.ubuntu.com’) child.logfile = sys.stdout child.expect(‘Name’) child.sendline(‘anonymous’) child.expect(‘Password’) child.sendline(‘anonymous’) child.expect(‘ftp>’) child.sendline(‘cd /ubuntu/dists/xenial’) child.expect(‘ftp>’) child.sendline(‘get InRelease’) child.expect(‘ftp>’) child.sendline(‘quit’)

Python: Lists

Python

This is post 4 of 5 in the series “Introduction to Python”   Let’s start out on this highly detailed page on handling lists: http://introtopython.org/lists_tuples.html Yes, this is a beast of a topic, and yes, you’ll be using these functions a lot. Note two things at the bottom of this page. First, see the heading …

Python: Hello World and Variables, Strings and Numbers

Python

This is post 3 of 5 in the series “Introduction to Python” We’re going to start with Chapter 1 of A Smarter Way. 1. Open a Linux terminal. Then run the command: python 2. Simple Print Output: “Hello World” print(“Hello, World!”) Older versions of Python (most often the classic 2.7) can use slightly different syntax: …

sudo and su –

Hacker Girl

This is post 9 of 11 in the series “The Linux Command Line” Both sudo and su are highly dangerous. The sudo command is used to run a following command as the super-user. Think “super-user do.” It lets regular users do rootly thing, like: sudo cat /etc/shadow You’ll be prompted for a password: Your Password. …