[Gambas-user] Reading the return from a shell command
Dave sharples
technoferret at ...598...
Fri Jan 21 17:37:55 CET 2005
On Fri, 2005-01-21 at 14:58, Rob wrote:
> On Friday 21 January 2005 05:01, Dave sharples wrote:
> > I am trying to issue a shell command from gambas with a couple
> > of arguments and use the return value in my app but I an
> > struggling to get a grasp on how to do it.
>
> You need to use the Process_Read event and grab the data as it
> comes in. Sometimes that's inconvenient and you want to do it
> asynchronously, so I wrote the Backtick function, which you can
> find in Help somewhere, but here it is again:
>
> STATIC PUBLIC FUNCTION Backtick(cmd AS String) AS String
> DIM result AS String
> DIM s AS String
> result = ""
> s = Temp()
> SHELL cmd & " >" & s WAIT
> TRY result = file.Load(s)
> TRY KILL s
> RETURN result
> END
>
> It's called "Backtick" because it does more or less what the
> backtick (``) quotes do in the Unix shell and in perl.
>
> Rob
>
Cheers Rob,
I think you misinterpreted my original post, I had found
your code as you say in the HELP, the problem I am having is
that I can get the 'return' but I need seperate it so that I
only have the first word of the returned string.
e.g return = "CAT DOG MOUSE"
I need to manipulate that so that I just have CAT
Does that make sense ?
More information about the User
mailing list