• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Python help needed please

Status
Not open for further replies.

Version_3

2[H]4U
Joined
Nov 19, 2007
Messages
4,076
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:

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:
\'
. The output consistently removes the '

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
 
Status
Not open for further replies.
Back
Top