Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
253 views
in Technique[技术] by (71.8m points)

video - How to make use of "&" command in TCL version 8.0 to make a proc or exec command run in background i.e in parallel on windows 7?

I am working on a project where I am using FFMPEG to capture video. The FFMPEG command is:

ffmpeg -f dshow  -t 00:00:10 -i "video=Integrated Webcam" -b 5000k -s 1280x720 c:/test/sample.avi

The link: https://www.tcl.tk/man/tcl8.5/tutorial/Tcl26.html make the use of the command:

exec myprog &

Here they have not specified what is myprog.

The link: Running shell commands in background, in a tcl proc make the use of command:

 eval exec [linsert $args 0 exec] >> $tempFile &

Here the command is not accepted as eval and exec is one after another, so it takes exec as a variable.

Help me, with the write right command which can be used to capture my video in the background with TCL version 8.0 and Windows 7.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The problem with this line:

eval exec [linsert $args 0 exec] >> $tempFile &

is multi-fold. Firstly, you've got a double exec (unlikely to be what you want!). Secondly, you've got a piece at the end which isn't being list protected despite running on a platform that quite often has spaces in filenames, making the filename be a bit of a timebomb waiting to go off (though I think it's not as bad on Windows 7 as it was on older versions, where common writable locations had spaces in the filename).

Now, if you were using a supported version of Tcl then we'd recommend writing that as:

exec {*}$args >> $tempFile &

(Indeed, this sort of thing was one of the key use-cases for the {*} syntax.)

However, you're on an ancient version so we have to do things the other way. It still helps that we've got the above as it guides where we need to insert non-list arguments in the overall list:

eval [linsert [linsert $args 0 exec] end >> $tempFile &]

Yes, this is hard to read and error-prone to write. Why do you think we literally changed the base language to put in something to address that? (Hardly anyone uses eval directly any more, and that's greatly reduced the defect rate in most folks' code.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...