Why doesn’t an import in an exec in a function work?
How about this: def test(): exec (code, globals()) f()
How about this: def test(): exec (code, globals()) f()
The docker shell syntax (which is just a string as the RUN, ENTRYPOINT, and CMD) will run that string as the parameter to /bin/sh -c. This gives you a shell to expand variables, sub commands, piping output, chaining commands together, and other shell conveniences. RUN ls * | grep $trigger_filename || echo file missing && … Read more
Am I suppose to create a separate .php file which then runs from the php cli to execute one of these functions? This is probably the way I would do it : the PHP webpage adds a record in database to indicate “this file has to be processed” and displays a message to the user … Read more
Even after the first command of your pipeline exits (and thust closes stdout=~fdPipe[1]), the parent still has fdPipe[1] open. Thus, the second command of the pipeline has a stdin=~fdPipe[0] that never gets an EOF, because the other endpoint of the pipe is still open. You need to create a new pipe(fdPipe) for each |, and … Read more
Ok, this is not simply an update but also an answer so I’m filing it as one. According to all information I could find, the following should theoretically do it: String[] cmd = {“explorer.exe”, “/select,\”C:\New”, “”, “”, “”, “”, “”, “”, “Folder\file.txt\””}; The multiple spaces have been broken into empty strings and the array version … Read more
If you’re doing it in php, why not use php code: In the running program: define(‘PIDFILE’, ‘/var/run/myfile.pid’); file_put_contents(PIDFILE, posix_getpid()); function removePidFile() { unlink(PIDFILE); } register_shutdown_function(‘removePidFile’); Then, in the watchdog program, all you need to do is: function isProcessRunning($pidFile=”/var/run/myfile.pid”) { if (!file_exists($pidFile) || !is_file($pidFile)) return false; $pid = file_get_contents($pidFile); return posix_kill($pid, 0); } Basically, posix_kill has … Read more
If you’re trying to build a dynamic query, there are easier ways. Here’s one using a list comprehension and str.join: query = ‘ & ‘.join([‘{}>{}’.format(k, v) for k, v in limits_dic.items()]) Or, using f-strings with python-3.6+, query = ‘ & ‘.join([f'{k}>{v}’ for k, v in limits_dic.items()]) print(query) ‘A>0 & C>-1 & B>2’ Pass the query … Read more
<?php function exec_enabled() { $disabled = explode(‘,’, ini_get(‘disable_functions’)); return !in_array(‘exec’, $disabled); } ?> EDIT: Fixed the explode as per Ziagl’s comment.
Per the docs, the exec statement takes two optional expressions, defaulting to globals() and locals(), and always performs changes (if any) in the locals() one. So, just be more explicit/specific/precise…: >>> def myfunc(): … exec(‘myvar=”boooh!”‘, globals()) … >>> myfunc() >>> myvar ‘boooh!’ …and you’ll be able to clobber global variables to your heart’s contents.
Use this: Runtime.getRuntime().exec(new String[] {“sh”, “-l”, “-c”, “./foo”}); Main point: don’t put the double quotes in. That’s only used when writing a command-line in the shell! e.g., echo “Hello, world!” (as typed in the shell) gets translated to: Runtime.getRuntime().exec(new String[] {“echo”, “Hello, world!”}); (Just forget for the moment that the shell normally has a builtin … Read more