Monday, February 18, 2008

python shell scripting 4

Step 1 command: sudo gedit hello

File Name: hello
hello world example:
#!/bin/bash
#
python hello.py

--------------------------------------------------

Step 2 command: sudo gedit hello.py

File Name: hello.py
hello world example in python:
#! /usr/local/bin/python
import os
if os.environ['USER']:
print 'Hello, '+os.environ['USER']

----------------------------------------------------

shell command to run program:
cd /home/user/scripts

shell Prompt: command:
------------------------------- --------
user@youhomecomputer:~/scripts$ ./hello

No comments: