exec

Docker exec linux terminal create alias

≯℡__Kan透↙ 提交于 2020-02-05 08:31:10
问题 I have a running and detached container. I want to create a command alias there before attaching to that container. When I am attached to the container and I type: alias bar='foo' an alias is created, and might be checked by: alias command. but if I want to do the same by docker exec command ie this way docker exec -it <container-name> /bin/bash -c "alias bar='foo'" it does not work, probably because when I'm attached to the container and type into its terminal /bin/bash -c "alias bar='foo'"

Node.js as service, exec doesn't work

我只是一个虾纸丫 提交于 2020-02-03 10:54:05
问题 I'm running Node.js project as service using nssm. When user clicks button on my nodejs website it should run require('child_process').exec('cmd /c batfile.bat', function({ res.send(somedata); }); but instead it just skips running bat file and jumps to res.send(somedata) . Why is that? When I run Node.js using cmd and npm start server.js it works fine. How can I make exec work while running nodejs as service? Edit, some code: require('child_process').exec('cmd /c batfile.bat', function(){ var

A change in macOS Sierra prevents “say” to be exec'd in a PHP script

|▌冷眼眸甩不掉的悲伤 提交于 2020-02-03 07:47:49
问题 I have a macOS server with a little site which converts text snippets to audio using say command. With upgrade to Sierra, everything went smooth except one thing: the say command doesn't work any more when wrapped in exec() in my PHP script. The page just times out. No error is caught either. <?php try { exec('/usr/bin/say "hello"'); } catch (Exception $e) { echo $e->getMessage(); } ?> Typically I would save the audio snippets with say -o filename but I tried all the variants and also other

QDialog exec() can not exit process

折月煮酒 提交于 2020-02-02 13:31:32
问题 int main(int argc, char *argv[]) { QApplication a(argc, argv); QDialog dlg; dlg.exec(); return a.exec(); } That's all my code, but when I close the window, The process isn't exit, it seems that drop in the loop a.exec() . 回答1: Generally speaking, calling any exec is a bad idea, other than QCoreApplication::exec() or QDrag::exec() . The presence of exec() and waitForXxx() methods is an enticing trap for the unwary. Those methods are "easy" to use, but that ease comes at a price of hard to

execvp/fork — how to catch unsuccessful executions?

邮差的信 提交于 2020-01-30 19:24:27
问题 Right now I'm writing a C program that must execute a child process. I'm not doing multiple child processes simultaneously or anything, so this is fairly straightforward. I am definitely executing the built-in shell programs (i.e. things like cat and echo) successfully, but I also need to be able to tell when one of these programs fails to execute successfully. I'm trying this with the following simplified code: int returnStatus; // The return status of the child process. pid_t pid = fork();

How can I dynamically execute function in current scope and add it as property of the calling function?

≡放荡痞女 提交于 2020-01-25 11:08:33
问题 I have some code like this: def f1(): <some stuff here> . . . @mylib.codegen def f2(args): f1() <some more stuff here> mylib.py : def codegen(fn): src = inspect.getsource(fn) original_ast = ast.parse(src) new_ast = transform_ast(original_ast) code_obj = compile(new_ast, '<auto-generated>', 'exec') myscope = {} exec code_obj in myscope fn.generated_fn = myscope['name'] # Where name is the binding created by execing code_obj To summarize, mylib.codegen is a decorator which parses code of f,

How can I dynamically execute function in current scope and add it as property of the calling function?

≡放荡痞女 提交于 2020-01-25 11:06:22
问题 I have some code like this: def f1(): <some stuff here> . . . @mylib.codegen def f2(args): f1() <some more stuff here> mylib.py : def codegen(fn): src = inspect.getsource(fn) original_ast = ast.parse(src) new_ast = transform_ast(original_ast) code_obj = compile(new_ast, '<auto-generated>', 'exec') myscope = {} exec code_obj in myscope fn.generated_fn = myscope['name'] # Where name is the binding created by execing code_obj To summarize, mylib.codegen is a decorator which parses code of f,

How to exec script to set iterm2 Badge from nodejs?

拟墨画扇 提交于 2020-01-24 13:43:22
问题 I get this bash script from Iterm2 official site. printf "\e]1337;SetBadgeFormat=%s\a" $(echo "text" | base64) I tried exec like bellow, there is no error, but failed to set iterm2 Badge var exec = require('child_process').exec; exec('printf "\e]1337;SetBadgeFormat=%s\a" $(echo "text" | base64)'); 回答1: setBadgeFormat.js => #!/usr/bin/env node var rawBadgeFormat = 'test' var base64BadgeFormat = new Buffer(rawBadgeFormat).toString('base64') var setBadgeFormatCmd = 'printf "\\e]1337

How to exec script to set iterm2 Badge from nodejs?

泄露秘密 提交于 2020-01-24 13:40:21
问题 I get this bash script from Iterm2 official site. printf "\e]1337;SetBadgeFormat=%s\a" $(echo "text" | base64) I tried exec like bellow, there is no error, but failed to set iterm2 Badge var exec = require('child_process').exec; exec('printf "\e]1337;SetBadgeFormat=%s\a" $(echo "text" | base64)'); 回答1: setBadgeFormat.js => #!/usr/bin/env node var rawBadgeFormat = 'test' var base64BadgeFormat = new Buffer(rawBadgeFormat).toString('base64') var setBadgeFormatCmd = 'printf "\\e]1337

Implement wait between processes in Java?

拜拜、爱过 提交于 2020-01-24 10:46:49
问题 I would like some help understanding and implementing a 'wait until process complete' between the various processes in my application, which need to proceed in a step-wise fashion . My java file runs a batch file which then runs a script. At the conclusion of this there are series of commands that I need to run (through the command line) in a consecutive manner. I'm using: Runtime.getRuntime().exec("cmd /c start " + command) to run my batch files and commands (not sure if that information is