Search - User list
Full Version: opfind and parameters
Root » Technical Discussion » opfind and parameters
jason_iversen
Hi all,

Hscript question here:

Has anyone got a quick and efficient way of querying all the parameters of a node? I can opfind find the node i'm interested in, but doesn't ever tell which query parameters matched my search criteria.

i.e. I want to find out which parameters, not just nodes, have a particular word in it.

Thanks,
Jason
deecue
well this will work if you're wanting to query the names of parameters, but i'm thinking you might be wanting to query the values of parameters (and probably words in parameters such as in an expression).

anyways, in case it helps, you can use opparm to kinda see whats going on. such as, if you want to match parameter names in all of your objects and list their values, you could type this in at the root:

opparm -q -d */*/* -v t

This will return all (unfortunately) sops and list those specifically with the translate parameter and also list their values.

The thing that really stinks about this is the list can get really long since it doesn't just filter out everything that doesn't match. Plus, the parameter name command doesn't allow wildcards (atleast i can't figure it out). And of course, you can't search parameter values, just names.

What would be nice is if opfind would just simply list the parameters and their values when searching…that or atleast allow opparm to search within parameter values and have wildcard capabilities.

I'd also like to know if anyone has a solution to this…

hth (but probably didn't),
dave
Antoine Durr
jason_iversen
Hi all,

Hscript question here:

Has anyone got a quick and efficient way of querying all the parameters of a node? I can opfind find the node i'm interested in, but doesn't ever tell which query parameters matched my search criteria.

i.e. I want to find out which parameters, not just nodes, have a particular word in it.

Thanks,
Jason

Can you use ‘opchange’ to substitute your word to some other bogus word, which will print out what changed?

Or, use something like:

set foo = `system(“echo + run(”opfind ..whatever“) + ”| perl -ne print if /match/")`

or something like that?

– Antoine
jason_iversen
I wish I could, but I have to run something (a weird SQL query) on each entry and then replace fragments of the path, so a simple opchange wouldnt work.

I came up with a fairly unsafe (ugly) hack where i opscript it and take an “arg()” a couple of places back to get the parameter name




set nodes=`execute(“opfind -i the_string_i _want”)`

# changing nodes
foreach node ($nodes)
set opscript = `execute(“opscript -b $node”)`
set loop = 1
while ( $loop > 0 )
set thisarg = `arg($opscript,$loop)`
set loop = `$loop+1`
if( `strmatch(“*the_string_i_want*”,“$thisarg”)` > 0 ) #search for string
set oldpath = `chs($node+“/”+arg(“$opscript”, $loop -3))` #chs the parameter name
echo HERE is where i do my parameter subsitution…
endif
if( `strlen(“$thisarg”)` == 0 ) # end of arguments
set loop = 0
break
endif
end
end


ps. would be quite nice to have opfind have a callback like the find .. -exec … in unix, eh?
Antoine Durr
jason_iversen
ps. would be quite nice to have opfind have a callback like the find .. -exec … in unix, eh?

Well, you kinda do!

hscript> mwrite /usr/tmp/foo.hip
hscript> unix hexpand /usr/tmp/foo.hip
hscript> set result = `system(“find /usr/tmp/foo.hip.dir -name blah -exec …”)`

– Antoine
jason_iversen
Heh heh.. thats an abstract thought.
I always like your solutions..

However, to print all parms containing a string..

opfind -i my_string -parameters -exec “echo parameter:$arg1 = \`chs(\”$arg1\“)\`”


this would be very useful, dont you agree?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB