Ok I know some books with real world examples and even some examples. Have you passed through starting python sticky? It have real world examples from this forum members.
Also in python.org there is tutorial and great Links. Consider also google with keywords such as "python tutorials". I have found many tutorials to be real world related. Anyway the books Imainly read are free one Like Think Python, a byte of python, learning python ...etc
Steve
evstevemd
Senior Poster
3,713 posts since Jun 2007
Reputation Points: 462
Solved Threads: 392
Let's try to translate a few key commands into Python...
Set srvr=%1
srvr = sys.argv[1]
sys.argv contains the list of input parameters. Index 0 ( [0] ) always contains the name of the program. Don't forget you'll need to import sys to access this item.
pause
time.sleep(1)
time.sleep(1) tells execution of the script to pause for 1 second. The value in the parenthesis can be any number of seconds. Don't forget you'll need to import time to make use of this function.
MKDIR \\%1\c$\Windows\System32\Macromed\Authorwa
Xcopy /y \\servername\ict$\Authorwa\*.* \\%1\C$\Windows\System32\Macromed\Authorwa
os.makedir( )
os.system( )
The os module contains many interesting functions. makedir() does exactly what it sounds like, and system() allows you to execute system commands. The easiest way to perform a copy (in my opinion) is to simply do a system command.
If you're going for cross-platform compatibility then use something like:
if sys.platform[:3] == 'win':
os.system( 'xcopy %s %s' % ( from_path, to_path ) )
elif sys.platform[:5] == 'linux':
os.system( 'cp -r %s %s' % ( from_path, to_path ) )
I guess the rest is pretty straight forward; print statements and string formatting
Refer to this link if you don't know about the power of % (string formatting)
[/QUOTE]
jlm699
Veteran Poster
1,112 posts since Jul 2008
Reputation Points: 355
Solved Threads: 292