[Gambas-user] Gambas app calling a PERL Script which calls a program (rtmpdump)
Rob
sourceforge-raindog2 at ...94...
Fri Sep 2 21:45:53 CEST 2011
Before I begin, I should tell you that I tried to duplicate your problem
but got the list of programmes in my Gambas app just fine using your EXEC
command, adjusted to find the copy of get_iplayer I just downloaded. I
created a form with a button and a textarea and wrote this in its class:
PUBLIC SUB Button1_Click()
DIM sType AS String
DIM sOutput AS String
stype = "TV"
EXEC ["/home/schmoe/build/get_iplayer-2.80/get_iplayer", "--force", "--
type=" & sType] TO sOutput
TextArea1.Text = sOutput
END
Please excuse the word wrapping above and below. The result of clicking the
button was the textarea being filled with the following:
get_iplayer v2.80, Copyright (C) 2008-2010 Phil Lewis
This program comes with ABSOLUTELY NO WARRANTY; for details use --
warranty.
This is free software, and you are welcome to redistribute it under
certain
conditions; use --conditions for details.
Matches:
1: 1911 Centenary Lecture - 1. David Lloyd George, BBC Parliament,
Factual,History,Politics,TV, default
2: 1911 Centenary Lecture - 3. Nancy Astor, BBC Parliament,
Factual,History,Politics,TV, default
3: 1911 Centenary Lecture - 5. Aneurin Bevan, BBC Parliament,
Factual,History,Politics,TV, default
[about 792 more lines...]
So what I have to say here is just theoretical. I'm using get_iplayer 2.80,
Gambas 2.16.
On Friday 02 September 2011 02:43, John Rose wrote:
> EXEC ["get_iplayer", "--force", "--type=" & sType] TO sOutput
> where sType & sOutput are both strings with sType having the value "TV".
> This is equivalent to "get_iplayer --force --type="TV" run in a Gnome
> Terminal except that the output to StdOut is placed in sOutput. This
> command works fine in a Gnome Terminal or even with >Output.txt keyed in
> at the end of the command so that the output goes to a file Output.txt.
Successfully redirecting the output may not be quite the same thing as EXEC
to a variable in Gambas, as outlined below.
> get_iplayer is a very complex PERL script which I do NOT want to amend.
> get_iplayer involves calling rtmpdump. rtmpdump can be executed in a
> Gnome Terminal. I do not even know what language rtmpdump is written in.
I'm familiar with rtmpdump, having compiled it myself a few times. It's
just C, but in this case that's probably not relevant.
To expand upon something Ian said in his reply (it's probably not
specifically a password prompt issue since you're able to redirect stdout
successfully), it may be that your version of rtmpdump and/or get_iplayer
tries to open a TTY (interactive terminal). I didn't see anything obvious
in the current version of get_iplayer or my copy of rtmpdump that should do
that, but it's almost 10,000 lines of code and the symptoms fit. It would
work fine in a terminal, even if you redirect input and output, but not
when run from another process outside of a terminal.
I ran into the same problem years ago when writing a Gambas program for a
client that needed to ssh somewhere. Benoit has made a lot of improvements
since then. Try something like this:
EXEC ["get_iplayer", "--force", "--type=" & sType] FOR INPUT OUTPUT
...
PUBLIC SUB Process_Read
DIM tmp as String
READ #LAST, tmp, lof(LAST)
sOutput = sOutput & tmp ' sOuput
END
INPUT OUTPUT simulates a tty when executing the process. I have no way of
testing this since it works for me as is, and since it's been a few years
since I did a Gambas project I'm not even sure that Read event syntax is
right. But I hope it's enough to point you in a helpful direction.
Rob
More information about the User
mailing list