gnotis
June 14th, 2009, 02:12 PM
To start, I have not been trained at all in programming. I'm trying to teach myself from scratch, which hasn't been easy. If there is anything that I'm missing the point on or needs to be added, please do so. Right now I have a fairly limited scope of understanding.
I understand that Python is an interpreted language as opposed to a compiled language.
The first part of a program imports modules. Modules are reusable pieces of code that perform some function. An example is the Time module. This means every time I need to find the time, I don't need to rewrite code to do so. I can do this, for example:
strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())I can define functions that are like mini modules I can reuse in my own code.
I'm stuck on classes. Can someone give me a brief layman terms definition?
I have on my local network, my main computer and two Linux based clients. The clients need to be updated regularly. I need to telnet in, shut down a process, delete two files, FTP replacement files and then restart the process. I've been told it would be easier to write a bash script to do this, but I'd like to learn to program.
I have an example from Pydocs (http://%5BURL%5Dhttp://www.python.org/doc/2.6/library/telnetlib.html?highlight=telnet#module-telnetlib%5B/URL%5D):
import getpass
import sys
import telnetlib
HOST = "localhost"
user = raw_input("Enter your remote account: ")
password = getpass.getpass()
tn = telnetlib.Telnet(HOST)
tn.read_until("login: ")
tn.write(user + "\n")
if password:
tn.read_until("Password: ")
tn.write(password + "\n")
tn.write("ls\n")
tn.write("exit\n")
print tn.read_all()I change the HOST variable, save the code, and make it executable. When I run it, nothing happens. When I select "run in terminal" nothing happens. When I run it in IDLE, it seems to work. Is there something I need to add to the code to make it run in terminal? If it does and there is a syntax error, will it show that in the terminal?
Sorry for the rudimentary questions, I'm just struggling. Does anyone live in central Florida that wants to make a few extra bucks and tutor me?
I understand that Python is an interpreted language as opposed to a compiled language.
The first part of a program imports modules. Modules are reusable pieces of code that perform some function. An example is the Time module. This means every time I need to find the time, I don't need to rewrite code to do so. I can do this, for example:
strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())I can define functions that are like mini modules I can reuse in my own code.
I'm stuck on classes. Can someone give me a brief layman terms definition?
I have on my local network, my main computer and two Linux based clients. The clients need to be updated regularly. I need to telnet in, shut down a process, delete two files, FTP replacement files and then restart the process. I've been told it would be easier to write a bash script to do this, but I'd like to learn to program.
I have an example from Pydocs (http://%5BURL%5Dhttp://www.python.org/doc/2.6/library/telnetlib.html?highlight=telnet#module-telnetlib%5B/URL%5D):
import getpass
import sys
import telnetlib
HOST = "localhost"
user = raw_input("Enter your remote account: ")
password = getpass.getpass()
tn = telnetlib.Telnet(HOST)
tn.read_until("login: ")
tn.write(user + "\n")
if password:
tn.read_until("Password: ")
tn.write(password + "\n")
tn.write("ls\n")
tn.write("exit\n")
print tn.read_all()I change the HOST variable, save the code, and make it executable. When I run it, nothing happens. When I select "run in terminal" nothing happens. When I run it in IDLE, it seems to work. Is there something I need to add to the code to make it run in terminal? If it does and there is a syntax error, will it show that in the terminal?
Sorry for the rudimentary questions, I'm just struggling. Does anyone live in central Florida that wants to make a few extra bucks and tutor me?