public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* bash command substitution
@ 2017-10-01  6:40 Vukovics Mihaly
  2017-10-01  8:19 ` Marco Atzeri
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Vukovics Mihaly @ 2017-10-01  6:40 UTC (permalink / raw)
  To: cygwin

Hello All,


I just wanted to use my bash script written in Debian 8 in 
cygwin(latest, win10 64bit), but does not work.
At a specific line there is a command substitution trying to get result 
from ffprobe:

VHEIGHT=$(ffprobe -v error -show_entries stream=width,height -of 
default=noprint_wrappers=1 ${OLDFILE} | grep "height" | cut -f2 -d'=')

For debugging purpose the same command is executed without putting the 
result into a variable, and works! Does anyone know why is it not 
working in cygwin?

Code:

...
declare -i VHEIGHT
ffprobe -v error -show_entries stream=width,height -of 
default=noprint_wrappers=1 ${OLDFILE} | grep height | cut -f2 -d'='
VHEIGHT=$(ffprobe -v error -show_entries stream=width,height -of 
default=noprint_wrappers=1 ${OLDFILE} | grep "height" | cut -f2 -d'=')
...

Here is some debug log (set -x):

....
+ declare -i VHEIGHT
+ ffprobe -v error -show_entries stream=width,height -of 
default=noprint_wrappers=1 P1220312.MP4
+ grep height
+ cut -f2 -d=
2160              # this woudl be the desired value
+ VHEIGHT=        # here the variable is empty!
+ VIDSTABDETECTOPTS=:shakiness=10
+ VIDSTABDETECTOPTS+=:result=P1220312-stab.trf
+ VIDSTABTRANSFORMOPTS+=:crop=keep

....

The same in Linux bash:

...
+ declare -i VHEIGHT
+ ffprobe -v error -show_entries stream=width,height -of 
default=noprint_wrappers=1 P1220312.MP4
+ grep height
+ cut -f2 -d=
2160
++ ffprobe -v error -show_entries stream=width,height -of 
default=noprint_wrappers=1 P1220312.MP4
++ grep height
++ cut -f2 -d=
+ VHEIGHT=2160     # here is the desired value in the variable!!!
...

Any suggestions?


-
Köszönettel:
Vukovics Mihály


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: bash command substitution
  2017-10-01  6:40 bash command substitution Vukovics Mihaly
@ 2017-10-01  8:19 ` Marco Atzeri
  2017-10-01 17:01 ` Steven Penny
  2017-10-01 17:54 ` Brian Inglis
  2 siblings, 0 replies; 6+ messages in thread
From: Marco Atzeri @ 2017-10-01  8:19 UTC (permalink / raw)
  To: cygwin

On 01/10/2017 08:40, Vukovics Mihaly wrote:
> Hello All,
> 
> 
> I just wanted to use my bash script written in Debian 8 in 
> cygwin(latest, win10 64bit), but does not work.
> At a specific line there is a command substitution trying to get result 
> from ffprobe:
> 
> VHEIGHT=$(ffprobe -v error -show_entries stream=width,height -of 
> default=noprint_wrappers=1 ${OLDFILE} | grep "height" | cut -f2 -d'=')
> 
> For debugging purpose the same command is executed without putting the 
> result into a variable, and works! Does anyone know why is it not 
> working in cygwin?
> 
> Code:
> 
> ...
> declare -i VHEIGHT
> ffprobe -v error -show_entries stream=width,height -of 
> default=noprint_wrappers=1 ${OLDFILE} | grep height | cut -f2 -d'='
> VHEIGHT=$(ffprobe -v error -show_entries stream=width,height -of 
> default=noprint_wrappers=1 ${OLDFILE} | grep "height" | cut -f2 -d'=')
> ...
> 
> Here is some debug log (set -x):
> 
> ....
> + declare -i VHEIGHT
> + ffprobe -v error -show_entries stream=width,height -of 
> default=noprint_wrappers=1 P1220312.MP4
> + grep height
> + cut -f2 -d=
> 2160              # this woudl be the desired value
> + VHEIGHT=        # here the variable is empty!
> + VIDSTABDETECTOPTS=:shakiness=10
> + VIDSTABDETECTOPTS+=:result=P1220312-stab.trf
> + VIDSTABTRANSFORMOPTS+=:crop=keep
> 
> ....
> 
> The same in Linux bash:
> 
> ...
> + declare -i VHEIGHT
> + ffprobe -v error -show_entries stream=width,height -of 
> default=noprint_wrappers=1 P1220312.MP4
> + grep height
> + cut -f2 -d=
> 2160
> ++ ffprobe -v error -show_entries stream=width,height -of 
> default=noprint_wrappers=1 P1220312.MP4
> ++ grep height
> ++ cut -f2 -d=
> + VHEIGHT=2160     # here is the desired value in the variable!!!
> ...
> 
> Any suggestions?
> 

from where ffprobe is coming for ?

  $ cygcheck -p ffprobe
Found 0 matches for ffprobe

If it is a windows program, may it is due to CRLF emitted instead of LF



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: bash command substitution
  2017-10-01  6:40 bash command substitution Vukovics Mihaly
  2017-10-01  8:19 ` Marco Atzeri
@ 2017-10-01 17:01 ` Steven Penny
  2017-10-01 17:16   ` Wouter van Doorn
  2017-10-01 17:54 ` Brian Inglis
  2 siblings, 1 reply; 6+ messages in thread
From: Steven Penny @ 2017-10-01 17:01 UTC (permalink / raw)
  To: cygwin

On Sun, 1 Oct 2017 08:40:51, Vukovics Mihaly wrote:
> VHEIGHT=$(ffprobe -v error -show_entries stream=width,height -of 
> default=noprint_wrappers=1 ${OLDFILE} | grep "height" | cut -f2 -d'=')
> 
> For debugging purpose the same command is executed without putting the 
> result into a variable, and works! Does anyone know why is it not 
> working in cygwin?

I am not having this trouble:

    $ VHEIGHT=$(ffprobe -v 0 -of compact=p=0:nk=1 -select_streams 0 \
    -show_entries stream=height 'The Master (2012).mp4')

    $ echo "$VHEIGHT"
    1040

but as Marco said, you might need to sanitize for carriage returns:

    $ echo "$VHEIGHT" | od -tcx1
    0000000   1   0   4   0  \r  \n
             31  30  34  30  0d  0a


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: bash command substitution
  2017-10-01 17:01 ` Steven Penny
@ 2017-10-01 17:16   ` Wouter van Doorn
  0 siblings, 0 replies; 6+ messages in thread
From: Wouter van Doorn @ 2017-10-01 17:16 UTC (permalink / raw)
  To: cygwin

Try the following:

echo $(echo hello | cat)

If that remains empty, (it should of course result in 'hello') you're
suffering from the same problem I have. And no, I did not get it resolved.
In which case I'd be elated if you could get anyone interested in finding a
solution!

If this happens to you, too, then the problem is that the pipe in a
subshell simply does not work. For the vast majority, it DOES work.

On 1 October 2017 at 18:01, Steven Penny <svnpenn@gmail.com> wrote:

> On Sun, 1 Oct 2017 08:40:51, Vukovics Mihaly wrote:
>
>> VHEIGHT=$(ffprobe -v error -show_entries stream=width,height -of
>> default=noprint_wrappers=1 ${OLDFILE} | grep "height" | cut -f2 -d'=')
>>
>> For debugging purpose the same command is executed without putting the
>> result into a variable, and works! Does anyone know why is it not working
>> in cygwin?
>>
>
> I am not having this trouble:
>
>    $ VHEIGHT=$(ffprobe -v 0 -of compact=p=0:nk=1 -select_streams 0 \
>    -show_entries stream=height 'The Master (2012).mp4')
>
>    $ echo "$VHEIGHT"
>    1040
>
> but as Marco said, you might need to sanitize for carriage returns:
>
>    $ echo "$VHEIGHT" | od -tcx1
>    0000000   1   0   4   0  \r  \n
>             31  30  34  30  0d  0a
>
>
>
> --
> Problem reports:       http://cygwin.com/problems.html
> FAQ:                   http://cygwin.com/faq/
> Documentation:         http://cygwin.com/docs.html
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
>
>

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: bash command substitution
  2017-10-01  6:40 bash command substitution Vukovics Mihaly
  2017-10-01  8:19 ` Marco Atzeri
  2017-10-01 17:01 ` Steven Penny
@ 2017-10-01 17:54 ` Brian Inglis
  2017-10-02 12:23   ` Vukovics Mihály
  2 siblings, 1 reply; 6+ messages in thread
From: Brian Inglis @ 2017-10-01 17:54 UTC (permalink / raw)
  To: cygwin

On 2017-10-01 00:40, Vukovics Mihaly wrote:
> I just wanted to use my bash script written in Debian 8 in cygwin(latest, win10
> 64bit), but does not work.
> At a specific line there is a command substitution trying to get result from
> ffprobe:
> VHEIGHT=$(ffprobe -v error -show_entries stream=width,height -of
> default=noprint_wrappers=1 ${OLDFILE} | grep "height" | cut -f2 -d'=')
> For debugging purpose the same command is executed without putting the result
> into a variable, and works! Does anyone know why is it not working in cygwin?
> Code:
> ...
> declare -i VHEIGHT
> ffprobe -v error -show_entries stream=width,height -of
> default=noprint_wrappers=1 ${OLDFILE} | grep height | cut -f2 -d'='
> VHEIGHT=$(ffprobe -v error -show_entries stream=width,height -of
> default=noprint_wrappers=1 ${OLDFILE} | grep "height" | cut -f2 -d'=')
> ...
> Here is some debug log (set -x):
> ....
> + declare -i VHEIGHT
> + ffprobe -v error -show_entries stream=width,height -of
> default=noprint_wrappers=1 P1220312.MP4
> + grep height
> + cut -f2 -d=
> 2160              # this woudl be the desired value
> + VHEIGHT=        # here the variable is empty!
> + VIDSTABDETECTOPTS=:shakiness=10
> + VIDSTABDETECTOPTS+=:result=P1220312-stab.trf
> + VIDSTABTRANSFORMOPTS+=:crop=keep
> ....
> The same in Linux bash:
> ...
> + declare -i VHEIGHT
> + ffprobe -v error -show_entries stream=width,height -of
> default=noprint_wrappers=1 P1220312.MP4
> + grep height
> + cut -f2 -d=
> 2160
> ++ ffprobe -v error -show_entries stream=width,height -of
> default=noprint_wrappers=1 P1220312.MP4
> ++ grep height
> ++ cut -f2 -d=
> + VHEIGHT=2160     # here is the desired value in the variable!!!
> ...
> Any suggestions?

Non-numeric characters in string - add "| cat -A" to the end of your pipe,
or equivalent od or xxd commands to see what's there.
There is no Cygwin package so how was ffprobe built - with Cygwin or Mingw?
May be extraneous trailing spaces or \r at end of input - try "set -o igncr".

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: bash command substitution
  2017-10-01 17:54 ` Brian Inglis
@ 2017-10-02 12:23   ` Vukovics Mihály
  0 siblings, 0 replies; 6+ messages in thread
From: Vukovics Mihály @ 2017-10-02 12:23 UTC (permalink / raw)
  To: cygwin

Hello,

it was compiled with mingw, and the \r was the issue, thanks!

---
Köszönettel:
Vukovics Mihály

On 2017-10-01 19:54, Brian Inglis wrote:
> On 2017-10-01 00:40, Vukovics Mihaly wrote:
>> I just wanted to use my bash script written in Debian 8 in 
>> cygwin(latest, win10
>> 64bit), but does not work.
>> At a specific line there is a command substitution trying to get 
>> result from
>> ffprobe:
>> VHEIGHT=$(ffprobe -v error -show_entries stream=width,height -of
>> default=noprint_wrappers=1 ${OLDFILE} | grep "height" | cut -f2 -d'=')
>> For debugging purpose the same command is executed without putting the 
>> result
>> into a variable, and works! Does anyone know why is it not working in 
>> cygwin?
>> Code:
>> ...
>> declare -i VHEIGHT
>> ffprobe -v error -show_entries stream=width,height -of
>> default=noprint_wrappers=1 ${OLDFILE} | grep height | cut -f2 -d'='
>> VHEIGHT=$(ffprobe -v error -show_entries stream=width,height -of
>> default=noprint_wrappers=1 ${OLDFILE} | grep "height" | cut -f2 -d'=')
>> ...
>> Here is some debug log (set -x):
>> ....
>> + declare -i VHEIGHT
>> + ffprobe -v error -show_entries stream=width,height -of
>> default=noprint_wrappers=1 P1220312.MP4
>> + grep height
>> + cut -f2 -d=
>> 2160              # this woudl be the desired value
>> + VHEIGHT=        # here the variable is empty!
>> + VIDSTABDETECTOPTS=:shakiness=10
>> + VIDSTABDETECTOPTS+=:result=P1220312-stab.trf
>> + VIDSTABTRANSFORMOPTS+=:crop=keep
>> ....
>> The same in Linux bash:
>> ...
>> + declare -i VHEIGHT
>> + ffprobe -v error -show_entries stream=width,height -of
>> default=noprint_wrappers=1 P1220312.MP4
>> + grep height
>> + cut -f2 -d=
>> 2160
>> ++ ffprobe -v error -show_entries stream=width,height -of
>> default=noprint_wrappers=1 P1220312.MP4
>> ++ grep height
>> ++ cut -f2 -d=
>> + VHEIGHT=2160     # here is the desired value in the variable!!!
>> ...
>> Any suggestions?
> 
> Non-numeric characters in string - add "| cat -A" to the end of your 
> pipe,
> or equivalent od or xxd commands to see what's there.
> There is no Cygwin package so how was ffprobe built - with Cygwin or 
> Mingw?
> May be extraneous trailing spaces or \r at end of input - try "set -o 
> igncr".

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-10-02 12:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-01  6:40 bash command substitution Vukovics Mihaly
2017-10-01  8:19 ` Marco Atzeri
2017-10-01 17:01 ` Steven Penny
2017-10-01 17:16   ` Wouter van Doorn
2017-10-01 17:54 ` Brian Inglis
2017-10-02 12:23   ` Vukovics Mihály

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).