I'm trying to understand some basic shell scripting. I have a script.sh, did the chmod, and was messing around with some pretty easy print statements by executing ./script.sh
Now how could I launch the shell displaying a prompt that includes the current working directory, and said prompt should accept a line of input and display a prompt each time?
To sum up the tools I understand so far: os.getcwd(), sys.stdin.readlines(), subprocess.Popen(['ls'], stdout=subproccess.PIPE)
Here is what I have so far.
#!/usr/bin/env python
import os
import sys
import subprocess
proc = subprocess.Popen(['ls'], stdout=subprocess.PIPE)
cwd = os.getcwd()
while True:
user_input = raw_input(str(cwd) + " >> ")
if user_input == 'ls':
print proc
if not foo:
sys.exit()
So this seems to work. At least the command prompt part, not exiting.