import os
for file in os.listdir("samples"):
print file
Python (os)
import os
# where are we?
cwd = os.getcwd()
print ("1", cwd)
# go down
os.chdir("samples")
print ("2", os.getcwd())
# go back up
os.chdir(os.pardir)
print ("3", os.getcwd())
Python (os)
import os
os.mkdir("test")
os.rmdir("test")
Python (os)
import os
import time
file = "samples/sample.jpg"
def dump(st):
mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime = st
print ("- size:", size, "bytes")
print ("- owner:", uid, gid)
print ("- created:", time.ctime(ctime))
print ("- last accessed:", time.ctime(atime))
print ("- last modified:", time.ctime(mtime))
print ("- mode:", oct(mode))
print ("- inode/dev:", ino, dev)
#
# get stats for a filename
st = os.stat(file)
print ("stat", file)
dump(st)
print
#
# get stats for an open file
fp = open(file)
st = os.fstat(fp.fileno())
print ("fstat", file)
dump(st)
Python (os)
import os
if os.name == "nt":
command = "dir"
else:
command = "ls -l"
os.system(command)
Python (send email) (gmail will probably not like)
import smtplib
server = smtplib.SMTP('stumail.cs.utahtech.edu', 25)
server.ehlo()
msg = "I like candy"
server.sendmail("joe@thegummibear.com", "foo@gmail.com", msg)
server.quit()
Might also need to read some google fu documentation