lets say I import os, import sys, have a couple user inputted variables which then are used in a command, why are escaped single quotes not working? So far, here's the command I'm trying to get to run in the interpreter:
and
For some reason I cannot do a
. The output consistently removes the '
Output seen in /tmp/test_out.txt is:
The purpose is to echo out the command used into a file before the command is actually ran. I could do a shell script, but for the other commands, shell script will not work. /admin/scripts/netgroupcat checks our nis netgroups for netgroupname.
Help a n00b out? OS is solaris 10 with I believe python 2.3
Code:
os.system("""echo """ + prompt + """ '''/admin/script/netgroupcat hosts_nas_erp_shr | /usr/bin/grep """ + sname + """ | /usr/bin/awk -F"(" \'{print \$2}\' | /usr/bin/awk -F''' | tee -a /tmp/test_out.txt""")
and
Code:
os.system("echo " + prompt + " '''/admin/script/netgroupcat hosts_nas_erp_shr | /usr/bin/grep " + sname +" | /usr/bin/awk -F\"(\" \'{print \$2}\' | /usr/bin/awk -F''' | tee -a /tmp/test_out.txt")
For some reason I cannot do a
Code:
\'
Output seen in /tmp/test_out.txt is:
root@srvr123 # /admin/script/netgroupcat hosts_nas_erp_shr | /usr/bin/grep erpitest2s | /usr/bin/awk -F"(" {print $2} | /usr/bin/awk -F
The purpose is to echo out the command used into a file before the command is actually ran. I could do a shell script, but for the other commands, shell script will not work. /admin/scripts/netgroupcat checks our nis netgroups for netgroupname.
Help a n00b out? OS is solaris 10 with I believe python 2.3