just wondering if there is a way to duplicate this unix command in hscript or an expression function
pwd|sed -e “s/\// /g”
this is taking the “/” and replacing it with a space
if pwd was /volumes/c/hello
it would return:
volumes c hello
more simple ex: sed -e “s/hello/goodbye/g”
that would replace hello with goodbye
wondering if there is something similar to this in expression functions or hscript
I saw the opreplace but that is just for operator names…I'm looking to be able to split up the paths and then use the arg function on them…
thanks in advance for any help!
:shock:
anyway to mimick a regular expression or sed?
5803 11 1-
- pyramation
- Member
- 176 posts
- Joined: July 2005
- Offline
-
- edward
- Member
- 8080 posts
- Joined: July 2005
- Offline
-
- pyramation
- Member
- 176 posts
- Joined: July 2005
- Offline
-
- pbowmar
- Member
- 7046 posts
- Joined: July 2005
- Offline
You can always call sed using the system() expression, with lots of tedious escaping of quotes and so forth.
Antoine at R+H wrote a bunch of custom functions that wrap sed, perl etc (mostly perl) so that you can avoid the tedious escaping most of the time.
Cheers,
Peter B
Antoine at R+H wrote a bunch of custom functions that wrap sed, perl etc (mostly perl) so that you can avoid the tedious escaping most of the time.
Cheers,
Peter B
Cheers,
Peter Bowmar
____________
Houdini 20.5.262 Win 10 Py 3.11
Peter Bowmar
____________
Houdini 20.5.262 Win 10 Py 3.11
-
- pyramation
- Member
- 176 posts
- Joined: July 2005
- Offline
So how exactly could you pipe something into sed using the system exp?
normally I would think of
pwd|sed -e “s/string/replace/g”
so when in houdini
set var = pwd|`system(“sed -e \”s/string/replace/g\“”)`
echo var
what would be the method of getting it to work?
and does the pipe work the same in houdini (“|”) ???
normally I would think of
pwd|sed -e “s/string/replace/g”
so when in houdini
set var = pwd|`system(“sed -e \”s/string/replace/g\“”)`
echo var
what would be the method of getting it to work?
and does the pipe work the same in houdini (“|”) ???
-
- edward
- Member
- 8080 posts
- Joined: July 2005
- Offline
-
- pyramation
- Member
- 176 posts
- Joined: July 2005
- Offline
-
- pyramation
- Member
- 176 posts
- Joined: July 2005
- Offline
-
- EigenAlex
- Member
- 639 posts
- Joined: July 2005
- Offline
Hey Lynch,
I tried using the pipe to send stuff out, looks like Hscript can't do it. Then again, I hardly every try to use HScript to do complex processing… Typically when I have to deal with patterns, I'd resort of Perl or Python and have it talk to Houdini instead via a socket. It probably is an overhead this way, but it is machine time as opposed to our time.
-Alex
I tried using the pipe to send stuff out, looks like Hscript can't do it. Then again, I hardly every try to use HScript to do complex processing… Typically when I have to deal with patterns, I'd resort of Perl or Python and have it talk to Houdini instead via a socket. It probably is an overhead this way, but it is machine time as opposed to our time.

-Alex
-
- pyramation
- Member
- 176 posts
- Joined: July 2005
- Offline
-
- pbowmar
- Member
- 7046 posts
- Joined: July 2005
- Offline
Hey,
Assuming strreplace() wasn't available (which it wasn't until H8) here's what you could do
/ -> set dir = `system(“pwd”)`
/ -> set newdir = `system(“echo $dir | sed -e \”s/\// /g\“”)`
Note that I have to escape the quotes in the sed string, making it more cumbersome than it should be.
However, if you did this a lot you could wrap that system() call in a custom Hscript function to avoid all the unpleasant escaping.
At R+H, they do lots of this type of thing with single line Perl calls, for example.
This should also work on Windows if you have the Cygwin package installed. I did a whole pipeline on Windows once, and this stuff worked fine with Cygwin.
Cheers,
Peter B
Assuming strreplace() wasn't available (which it wasn't until H8) here's what you could do
/ -> set dir = `system(“pwd”)`
/ -> set newdir = `system(“echo $dir | sed -e \”s/\// /g\“”)`
Note that I have to escape the quotes in the sed string, making it more cumbersome than it should be.
However, if you did this a lot you could wrap that system() call in a custom Hscript function to avoid all the unpleasant escaping.
At R+H, they do lots of this type of thing with single line Perl calls, for example.
This should also work on Windows if you have the Cygwin package installed. I did a whole pipeline on Windows once, and this stuff worked fine with Cygwin.
Cheers,
Peter B
Cheers,
Peter Bowmar
____________
Houdini 20.5.262 Win 10 Py 3.11
Peter Bowmar
____________
Houdini 20.5.262 Win 10 Py 3.11
-
- pyramation
- Member
- 176 posts
- Joined: July 2005
- Offline
thanks man! I actually am running cygwin on windows and fedora core 4….so I am happy either way…
I just could't wrap my head around the idea how to pipe it into the sed…but setting the variable first should have been obvious….
yeah agreed you could make a function out of this and use args to handle the input…that would be a great idea.
My next feat is to learn perl for sure…just got into the word of programming somewhat recently and have found most of my time using unix and hscript. I've heard perl is quick and dirty…sounds fun. :wink:
I just could't wrap my head around the idea how to pipe it into the sed…but setting the variable first should have been obvious….
yeah agreed you could make a function out of this and use args to handle the input…that would be a great idea.
My next feat is to learn perl for sure…just got into the word of programming somewhat recently and have found most of my time using unix and hscript. I've heard perl is quick and dirty…sounds fun. :wink:
-
- Quick Links


