exec

Using exec to define and get the value from variables raises NameError

自闭症网瘾萝莉.ら 提交于 2021-01-29 14:53:02
问题 Right now I'm working on a project that will ask for a runner's name, 1 mile, 2 mile, and 5 miles times and generate data based off that. The requirement is to have enough entries for 7 runners but I thought I'd add the ability to add any number of runners by using exec() . However, when trying to read data from the variables defined within them, I get a NameError: name 'entry2' is not defined but not for entry0 and entry1 , so I was wondering if anyone could help me out on these. In case it

Node.js: Sanitize untrusted user input for exec()

两盒软妹~` 提交于 2021-01-28 23:01:41
问题 Small example, reduced from a REST API node.js app: const { exec } = require('child_process'); var userInput = 'untrusted source'; var cmd = `/bin/echo "${userInput}"`; exec(cmd, function(err, stdout, stderr) { console.log('echo: ' + stdout); }); Assuming the userInput is from an untrusted source, what needs to be done avoid any vulnerability? For example, the quoted "${userInput}" parameter for echo avoids input 'evil spirit; rm -rf /' from causing damage. What else needs to be done to stay

Execvp doesn't return an error on an unknown command

◇◆丶佛笑我妖孽 提交于 2021-01-28 11:11:13
问题 I have the following code that forks a child and executes the command "a", which is an unknown command. However, execvp does not return an error and instead, "success" is printed. The same thing happens if I do "mv a b", when the file "a" does not exist. How should I capture and handle these errors? int main ( int argc, char **argv ){ pid_t pid; char *execArgs[] = { "a", NULL }; pid = fork(); // if fork fails if (pid < 0){ exit(EXIT_FAILURE); } else if (pid == 0){ execvp(execArgs[0], execArgs

bundle exec not working in Windows

风流意气都作罢 提交于 2021-01-28 07:35:58
问题 I am following the Redmine Install Tutorial on step 5 it says Step 5 - Session store secret generation This step generates a random key used by Rails to encode cookies storing session data thus preventing their tampering. Generating a new secret token invalidates all existing sessions after restart. bundle exec rake generate_secret_token I'm on Windows 10. When I try to do bundle exec in CMD, I get cannot find the path specified. For whatever reason I cannot find any reference to this problem

php exec crontab not working

北城以北 提交于 2021-01-28 02:22:30
问题 I trying on my local CentOS 5.3 server, when I try to execute below line in my php code from apache webserver exec("crontab -l", $output, $arg); The $arg reply 127 (command not found code) Then I changed below code exec("/usr/bin/crontab -l", $output, $arg); The $arg reply 126 (Permission problem code) Here is my current permission of /usr/bin/crontab -rwsr-sr-x 1 root root 311288 Mar 15 2007 /usr/bin/crontab. And there is no /etc/cron.allow and /etc/cron.deny file. I already turned off Safe

Converting a PDF to JPG with ImageMagick in PHP Gives Odd Letter Spacing

佐手、 提交于 2021-01-27 07:28:13
问题 I am trying to convert a PDF to a JPG with a PHP exec() call, which looks like this: convert page.pdf -resize 716x716 page.jpg For some reason, the JPG comes out with janky text, despite the PDF looking just fine in Acrobat and Mac Preview. Here is the original PDF: http://whit.info/dev/conversion/page.pdf and here is the janktastic output: http://whit.info/dev/conversion/page.jpg The server is a LAMP stack with PHP 5 and ImageMagick 6.2.8. Can you help this stumped Geek? Thanks in advance,

Converting a PDF to JPG with ImageMagick in PHP Gives Odd Letter Spacing

假如想象 提交于 2021-01-27 07:27:08
问题 I am trying to convert a PDF to a JPG with a PHP exec() call, which looks like this: convert page.pdf -resize 716x716 page.jpg For some reason, the JPG comes out with janky text, despite the PDF looking just fine in Acrobat and Mac Preview. Here is the original PDF: http://whit.info/dev/conversion/page.pdf and here is the janktastic output: http://whit.info/dev/conversion/page.jpg The server is a LAMP stack with PHP 5 and ImageMagick 6.2.8. Can you help this stumped Geek? Thanks in advance,

Converting a PDF to JPG with ImageMagick in PHP Gives Odd Letter Spacing

一曲冷凌霜 提交于 2021-01-27 07:27:03
问题 I am trying to convert a PDF to a JPG with a PHP exec() call, which looks like this: convert page.pdf -resize 716x716 page.jpg For some reason, the JPG comes out with janky text, despite the PDF looking just fine in Acrobat and Mac Preview. Here is the original PDF: http://whit.info/dev/conversion/page.pdf and here is the janktastic output: http://whit.info/dev/conversion/page.jpg The server is a LAMP stack with PHP 5 and ImageMagick 6.2.8. Can you help this stumped Geek? Thanks in advance,

PHP Exec SCP does not copy the file to the remote server

会有一股神秘感。 提交于 2021-01-26 20:01:50
问题 I need a file from a server to another server (I own both) using PHP. I have the following script: <?php exec('scp /home/pat/file1.tst pat@myserver.com:/home/pat/file1.txt'); I get this error: Disallowed system call: SYS_pipe What is that error? and how can I fix it? 回答1: PHP environment does not allow exec on your server. 回答2: This is kinda late, I know, but you might have better luck with phpseclib's pure PHP SCP implementation: https://raw.github.com/phpseclib/phpseclib/master/phpseclib

How to avoid command injection in node child_process exec

谁说我不能喝 提交于 2021-01-07 03:01:29
问题 I am opening IE browser in(via) my electron application using Node child_process . Code below: var cp = require('child_process'); var browser = cp.exec('start', 'iexplore', ['-private', args.url]); This is raising command injection warning when I run Fortify analysis on this code. Also, this args.url is fetched from api resource (stored in db) and is not related to any user input on this client application. Please help me escape this. I also tried spawn , but no success. 回答1: As a rule of