exec

Golang get command tty output

社会主义新天地 提交于 2021-02-08 05:23:00
问题 I'm using go's exec Run command to get command output, which works great when the command 'Stdout' field is set to os.Stdout , and the error is sent to os.Stderr . I want to display the output and the error output to the console, but I also want my program to see what the output was. I then made my own Writer type that did just that, wrote both to a buffer and printed to the terminal. Here's the problem—some applications change their output to something much less readable by humans when it

When should I use O_CLOEXEC when I open file in Linux?

六眼飞鱼酱① 提交于 2021-02-07 11:16:17
问题 My process forks several times, and each time the child will exec - means I want it to run some other program. In the main process I open a file descriptor with the open() syscall. Would it be correct to give it a flag O_CLOEXEC so the new program that I run with exec() wouldn't has the fd resource? 回答1: Yes, unless you need the program you exec to have access to that file descriptor. You can also close the file descriptor manually in the child process before calling exec, but that's more

When should I use O_CLOEXEC when I open file in Linux?

只愿长相守 提交于 2021-02-07 11:15:23
问题 My process forks several times, and each time the child will exec - means I want it to run some other program. In the main process I open a file descriptor with the open() syscall. Would it be correct to give it a flag O_CLOEXEC so the new program that I run with exec() wouldn't has the fd resource? 回答1: Yes, unless you need the program you exec to have access to that file descriptor. You can also close the file descriptor manually in the child process before calling exec, but that's more

Any equivalent to subprocess in PHP?

不打扰是莪最后的温柔 提交于 2021-02-07 06:01:50
问题 In Java and Python, you have the ProcessBuilder or subprocess modules that let you easily start a process using unescaped strings e.g. ["ls", "some unescaped directory name"] - they also give you powerful tools like access to read from stdout, stderr. Is there any equivalent feature of PHP that is more intelligent and useful than just exec() ? 回答1: The closest equivalent that gives you access to stdin , stdout , and stderr , with two-way communication, would be proc_open(). Here's the example

PHP exec() Not Working With ffmpeg

邮差的信 提交于 2021-02-07 03:49:39
问题 I'm attempting to run the following command in PHP (on Ubuntu): <?php if (exec("/home/johnboy/ffmpeg/ffmpeg -i test1.mp4 -acodec aac -ab 128kb -vcodec mpeg4 -b 1220kb -mbd 1 -s 320x180 final_video.mov")) { echo "Success"; } else { echo "No good"; } And I always get "No good" echoed back, and no file created. Interestingly, if I run the same exact command in Shell, it works, no problems. Also, when I run the same code above, but subsitute "whoami" instead of the ffmpeg stuff, it works. (It

PHP exec() Not Working With ffmpeg

橙三吉。 提交于 2021-02-07 03:47:43
问题 I'm attempting to run the following command in PHP (on Ubuntu): <?php if (exec("/home/johnboy/ffmpeg/ffmpeg -i test1.mp4 -acodec aac -ab 128kb -vcodec mpeg4 -b 1220kb -mbd 1 -s 320x180 final_video.mov")) { echo "Success"; } else { echo "No good"; } And I always get "No good" echoed back, and no file created. Interestingly, if I run the same exact command in Shell, it works, no problems. Also, when I run the same code above, but subsitute "whoami" instead of the ffmpeg stuff, it works. (It

PHP exec() Not Working With ffmpeg

纵饮孤独 提交于 2021-02-07 03:47:38
问题 I'm attempting to run the following command in PHP (on Ubuntu): <?php if (exec("/home/johnboy/ffmpeg/ffmpeg -i test1.mp4 -acodec aac -ab 128kb -vcodec mpeg4 -b 1220kb -mbd 1 -s 320x180 final_video.mov")) { echo "Success"; } else { echo "No good"; } And I always get "No good" echoed back, and no file created. Interestingly, if I run the same exact command in Shell, it works, no problems. Also, when I run the same code above, but subsitute "whoami" instead of the ffmpeg stuff, it works. (It

PHP exec() Not Working With ffmpeg

为君一笑 提交于 2021-02-07 03:46:28
问题 I'm attempting to run the following command in PHP (on Ubuntu): <?php if (exec("/home/johnboy/ffmpeg/ffmpeg -i test1.mp4 -acodec aac -ab 128kb -vcodec mpeg4 -b 1220kb -mbd 1 -s 320x180 final_video.mov")) { echo "Success"; } else { echo "No good"; } And I always get "No good" echoed back, and no file created. Interestingly, if I run the same exact command in Shell, it works, no problems. Also, when I run the same code above, but subsitute "whoami" instead of the ffmpeg stuff, it works. (It

TSQL make EXECUTE statement synchronous

心已入冬 提交于 2021-02-05 07:39:16
问题 I have two TSQL EXEC statements EXECUTE (N'MyDynamicallyGeneratedStoredProcedure') -- return 0 on success SELECT @errCode = @@ERROR ; IF (@errCode = 0) BEGIN EXEC 'A Sql Statement using ##temptable created from first', @returnValue END How do I make the two EXEC's synchronous? ; Right now the second EXEC does not wait for the first EXECUTE to complete. I tried issuing a WaitFor Delay, It waits but the second EXEC statement is never returing back. Thanks. Update, Here is more info: First

Python3 exec, why returns None?

六眼飞鱼酱① 提交于 2021-02-04 08:32:26
问题 When the code below this text, and returns the result None why? with open('exx.py', 'rb') as file: ff = compile(file.read(), 'exx.py', 'exec') snip_run = exec(ff, locals()) if 'result' in locals(): print(snip_run, result) else: print(snip_run) Result: 777777 None Module code exx.py: print('777777') 回答1: The problem of course is not only that print returns None , it is that exec returns None, always. >>> exec('42') is None True If you'd need the return value, you'd use eval : >>> eval('42') 42