Jump to content

System() Driving Me Mad


Recommended Posts

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'".

:angry:

Link to comment
Share on other sites

I assume you'd called this ugly

and 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? :unsure:)

..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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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"),"

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...