Google 그룹스는 더 이상 새로운 유즈넷 게시물 또는 구독을 지원하지 않습니다. 과거의 콘텐츠는 계속 볼 수 있습니다.

Output of exec to stdout

조회수 30회
읽지 않은 첫 메시지로 건너뛰기

Cecil Westerhof

읽지 않음,
2018. 2. 12. 오전 7:14:0618. 2. 12.
받는사람
I have the following command:
exec youtube-dl -f ${format} -o %(title)s-%(id)s.%(ext)s ${link}

I would like to have the from the youtube-dl command going to the
console. How could I do that?

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Gerald Lester

읽지 않음,
2018. 2. 12. 오전 7:16:3118. 2. 12.
받는사람
On 02/12/2018 06:02 AM, Cecil Westerhof wrote:
> I have the following command:
> exec youtube-dl -f ${format} -o %(title)s-%(id)s.%(ext)s ${link}
>
> I would like to have the from the youtube-dl command going to the
> console. How could I do that?
>

See the answers to your post on "Output from a pipe in a scroll-able
window", but instead of inserting into a text widget, use [puts stdout]
to write it to the console.


--
+----------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email: Gerald...@kng-consulting.net |
+----------------------------------------------------------------------+

Rich

읽지 않음,
2018. 2. 12. 오전 7:23:3118. 2. 12.
받는사람
Cecil Westerhof <Ce...@decebal.nl> wrote:
> I have the following command:
> exec youtube-dl -f ${format} -o %(title)s-%(id)s.%(ext)s ${link}
>
> I would like to have the from the youtube-dl command going to the
> console. How could I do that?

What OS?

If Linux, just use exec's redirect option to redirect stdout to
/dev/stdout (and start your program from a xterm, rxvt, or other
terminal).

If Windows, well, you've got some work to do in that case.

Cecil Westerhof

읽지 않음,
2018. 2. 12. 오전 7:44:0518. 2. 12.
받는사람
Cecil Westerhof <Ce...@decebal.nl> writes:

> I have the following command:
> exec youtube-dl -f ${format} -o %(title)s-%(id)s.%(ext)s ${link}
>
> I would like to have the from the youtube-dl command going to the
> console. How could I do that?

I found a reasonable way. Instead of using exec, I use the following:
set fetch [open "|youtube-dl -f ${format} -o %(title)s-%(id)s.%(ext)s ${link}" RDONLY]
while {-1 != [gets ${fetch} line]} {
puts ${line}
}
close ${fetch}

Five lines instead of one and it displays all the download progress
lines on a new line, but for the moment I can live with that.

At the moment I am going to put it in an GUI that is not a problem and
maybe even preferred. ;-)

Cecil Westerhof

읽지 않음,
2018. 2. 12. 오전 8:44:0618. 2. 12.
받는사람
Rich <ri...@example.invalid> writes:

> Cecil Westerhof <Ce...@decebal.nl> wrote:
>> I have the following command:
>> exec youtube-dl -f ${format} -o %(title)s-%(id)s.%(ext)s ${link}
>>
>> I would like to have the from the youtube-dl command going to the
>> console. How could I do that?
>
> What OS?

In my case Linux, but I like to write code that is system independent.


> If Linux, just use exec's redirect option to redirect stdout to
> /dev/stdout (and start your program from a xterm, rxvt, or other
> terminal).

Of-course. I should have thought about that.


> If Windows, well, you've got some work to do in that case.

I already found a reasonable solution. The nice thing about this one
is that I can put the output also in a logging database.

Cecil Westerhof

읽지 않음,
2018. 2. 12. 오전 8:44:0618. 2. 12.
받는사람
Cecil Westerhof <Ce...@decebal.nl> writes:

> Cecil Westerhof <Ce...@decebal.nl> writes:
>
>> I have the following command:
>> exec youtube-dl -f ${format} -o %(title)s-%(id)s.%(ext)s ${link}
>>
>> I would like to have the from the youtube-dl command going to the
>> console. How could I do that?
>
> I found a reasonable way. Instead of using exec, I use the following:
> set fetch [open "|youtube-dl -f ${format} -o %(title)s-%(id)s.%(ext)s ${link}" RDONLY]
> while {-1 != [gets ${fetch} line]} {
> puts ${line}
> }
> close ${fetch}
>
> Five lines instead of one and it displays all the download progress
> lines on a new line, but for the moment I can live with that.

Solved it for Linux:
set fetch [open "|youtube-dl -f ${format} -o %(title)s-%(id)s.%(ext)s ${link}" RDONLY]
while {-1 != [gets ${fetch} line]} {
if {${line} == ""} {
break
}
puts ${line}
}
while {-1 != [gets ${fetch} line]} {
puts -nonewline [format "\r%-80s" ${line}]
flush stdout
}
puts ""
close ${fetch}

Is there a tcl way to put the cursor back to the start of the line, so
I can make it OS independent?

Ralf Fassel

읽지 않음,
2018. 2. 12. 오전 9:22:2818. 2. 12.
받는사람
* Cecil Westerhof <Ce...@decebal.nl>
| Cecil Westerhof <Ce...@decebal.nl> writes:
>
| > I have the following command:
| > exec youtube-dl -f ${format} -o %(title)s-%(id)s.%(ext)s ${link}
| >
| > I would like to have the from the youtube-dl command going to the
| > console. How could I do that?
>
| I found a reasonable way. Instead of using exec, I use the following:
| set fetch [open "|youtube-dl -f ${format} -o %(title)s-%(id)s.%(ext)s ${link}" RDONLY]
| while {-1 != [gets ${fetch} line]} {
| puts ${line}
| }

If 'puts' works, you might as well do

exec youtube-dl -f ${format} -o %(title)s-%(id)s.%(ext)s ${link} >@stdout 2>@stderr &

This redirection from TCL might fail on Windows when there is no
stdout/stderr open.

HTH
R'

Rich

읽지 않음,
2018. 2. 12. 오전 11:53:3418. 2. 12.
받는사람
Cecil Westerhof <Ce...@decebal.nl> wrote:
> Is there a tcl way to put the cursor back to the start of the line,
> so I can make it OS independent?

This depends upon the terminal under which it is running.

The closest you can get from plain tcl is a -nonewline puts with a \r
where you want the cursor to return to the start of a line.

And, whether a \r, when output, actually does return to the start of a
line is terminal (configuration) dependent (i.e., if your terminal were
set to interpret \r as if it were \n, you'd get plural lines anyway).

새 메시지 0개