[Gambas-user] How to capture /dev/null to a string ?

Bruce Steers bsteers4 at gmail.com
Sat Mar 20 12:34:11 CET 2021


Correction..
That command you posted does not look right.
I would thought it would be this...
Dim myString As String
Shell "ffmpeg -i audo.mp3 -af \"volumedetect\" -f null >/dev/null 2>&1" To
myString

Note >/dev/null   using the > redirects the standard output to null (where
it cannot be retrieved)

Using 2> redirects standard error output. Using 2>&1 redirects error output
to standard output.
(do not confuse error output for meaning output only if an error. ffmpeg
uses standard out to output some info and error out to output other info.)

You will have to experiment or get advice on an ffmpeg forum to best
understand the ffmpeg command methods.

But the important bits of info you need is using
*Shell "command" To myString*
that's how to capture shell output in gambas.

And use...
*Shell "ffmpeg args 2>&1" To myString*
To capture all output.
Or..
*Shell "ffmpeg args >/dev/null 2>&1" To myString*

Might give the result you want.
BruceS

On Sat, 20 Mar 2021 at 10:51, Bruce Steers <bsteers4 at gmail.com> wrote:

> not sure you can.
> you would not use >/dev/null and capture the output.
>
> I believe ffmpeg uses stderr to output some info
>
> So try it with ">2&1"
>
> Dim myString As String
> Shell "ffmpeg -i audo.mp3 -af \"volumedetect\" -f null /dev/null 2>&1" To
> myString
>
> that redirects stderr to stdout and sends any output text to the myString
> variable
>
> BruceS
>
> On Sat, 20 Mar 2021 at 05:46, Vinode Singh Ujlain <ujlain at gmail.com>
> wrote:
>
>> How do I capture the output of this command line (using shell/exec) to a
>> string for further REGEX parsing ?
>> ffmpeg -i audo.mp3 -af "volumedetect" -f null /dev/null
>>
>> Warm Regards - UZI
>> ------------------------------
>>
>> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20210320/90fb770e/attachment.htm>


More information about the User mailing list