Jason Posted March 19, 2006 Share Posted March 19, 2006 Hi there, I am going CRAZY with system() and how it seems to strip off quotes. I am trying to populate a menu script. Anyone have any good ideas for this, taking the following into account? Boiled down to an example: In a file (myfile.txt), put: "Item A" "Item B" Now, in hscript: Director-> echo `system("cat myfile.txt")` Item A Item B Is this a bug in system()? Why won't the quotation marks make it across? I want the verbatim output from the cat command. Anyone have any kung fu for this type of thing? ...without severely ugly kludges, like nesting quotes "'Item A'". Quote Link to comment Share on other sites More sharing options...
sibarrick Posted March 19, 2006 Share Posted March 19, 2006 I assume you'd called this ugly and I've only tested on windows but \"Item A\" \"Item B\" works for me Quote Link to comment Share on other sites More sharing options...
Jason Posted March 19, 2006 Author Share Posted March 19, 2006 I assume you'd called this uglyand I've only tested on windows but \"Item A\" \"Item B\" works for me 25749[/snapback] Unforunately I have little control over the program that prints out this stuff. In fact, if I run this output through "sed", like this: set cmd = listAssets -c $arg1 #this generates the list (not my prog) echo $cmd | sed 's/\"/\\\\\"/g' > $TEMP/exec.sh set results = "`system("source $TEMP/exec.sh")` echo $results (pretty, eh? ) ..but the problem is, soon enough this output courses through an execute() too - right after the system, the quotes are stripped off once again. There is no way to know how many executes() are going pass this around and so no way to know how many times I need to escape it. In the example above I couldn't figure out wtf to do to get the escaping correct to execute it all in a single line, so I broke it down into discrete steps - hence the added ugliness. This is a common malady affecting many hscript tools; there is no respect for quotations anywhere. I go crazy with escaping strings all over the place just to push things through. Please SESI, please can we have a real scripting language embedded? No matter what we do we have to eventually end up in hscript and thats where it all falls apart for me. Quote Link to comment Share on other sites More sharing options...
Jason Posted March 19, 2006 Author Share Posted March 19, 2006 I think why this is frustrating is that it emulates shell scripting but shell scripting correctly preserves the quotes. Shell: %> set a=`cat a.txt` %> echo $a "poop poop" "dog" Hscript: hscript -> set a=`system("cat a.txt")` hscript -> echo $a poop poop dog It's currently impossible to keep things tokenized in hscript without major effort. Quote Link to comment Share on other sites More sharing options...
RickWork Posted March 20, 2006 Share Posted March 20, 2006 Please SESI, please can we have a real scripting language embedded? No matter what we do we have to eventually end up in hscript and thats where it all falls apart for me. 25750[/snapback] So very true. I have been fighting with hscript all week with similar stuff. Quote Link to comment Share on other sites More sharing options...
sibarrick Posted March 20, 2006 Share Posted March 20, 2006 I'm not sure this will be possible in your situation, but could you use a character that does get preserved and then switch it for quotes during the last call inside houdini. So in your example something like this set results = "`strreplace(system("source $TEMP/exec.sh")," Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.