我正在用PHP编写的github创建部署脚本.我正在使用shell_exec命令运行git pull哪个工作正常.
拉出错误时会出现问题.如果我在终端中执行此操作,则会收到完整错误.例如:
git pull origin master
Updating f706749..8468d24
test.txt: needs update
error: Entry 'test.txt' not uptodate. Cannot merge.
Run Code Online (Sandbox Code Playgroud)
但是当我在shell_exec输出中运行相同的命令被截断为just
Updating f706749..8468d24
test.txt: needs update
Run Code Online (Sandbox Code Playgroud)
错误消息正在被切断,可能是因为它是来自先前响应的响应.有没有办法返回完整的输出?
我正在使用红帽企业版n尝试制作一个简单的php页面..
当我尝试...
// html code
<?php
echo exec(<cmd>);
?>
// rest html code
Run Code Online (Sandbox Code Playgroud)
它的工作正常
但是当试用......
// html code
<?php
exec(<cmd>);
?>
// rest html code
Run Code Online (Sandbox Code Playgroud)
它不起作用
即使像cat,ls等简单的命令也不起作用,我也尝试过2 > &1没有错误打印.
什么可能是错误???
我正在使用exec来运行这样的后台脚本:
$command = "/usr/local/bin/php public_html/r/index.php tools $action process $params > /dev/null &";
exec($command);
Run Code Online (Sandbox Code Playgroud)
问题是:它不工作.
提示:
exec命令已启用(我可以执行任何命令而不会出现问题).有任何想法吗?
我正在从Java程序执行shell脚本.我使用Runtime类实现了它.以下是我实施的代码
final StringBuilder sb = new StringBuilder("test.sh");
sb.append("/path to/my/text file");
final Process p = Runtime.getRuntime().exec(sb.toString());
Run Code Online (Sandbox Code Playgroud)
这里sb是字符串缓冲区对象,我在其中附加我的参数并在exec方法中使用它.但问题是我传递的参数"/ path to/my/text file"被认为是4个参数
/path
to
/my/text
file
Run Code Online (Sandbox Code Playgroud)
但是如果在shell中运行test.sh"/ path to/my/text file",它被视为单个参数.如何使用Java代码实现相同的功能,我需要将此路径与空格作为单个参数进行考虑.任何请你真的很感激.
我有一个PHP脚本,我想展示它的progess.从这个超级问题和完美答案如何将进度条添加到shell脚本?我试图模仿这种行为:
shell_exec("echo -ne '###### 30%'\r");
Run Code Online (Sandbox Code Playgroud)
但没有任何东西被打印到屏幕上.
我的猜测是因为STDOUT不正确,或者我必须回应回声吗?
echo shell_exec("echo -ne '###### 30%'\r");
Run Code Online (Sandbox Code Playgroud) 我必须使用 Fred 的 ImageMagick 脚本创建图像的过渡序列,特别是fx 过渡。
在我的 php 代码中,我将所有图像调整为标准尺寸,然后将所有这些图片重命名为 pic000001.jpg、pic000002.jpg、pic000003.jpg 等(我用 $count 进行计数),然后我愿意:
$frameIndex=0;
$frames=18;
//for all the pic000001.jpg, pic000002.jpg, pic000003.jpg.... do a transition
//between them
for($seq=1;$seq<$count;$seq++){
//here I take a picture and the next(IE pic000001 and pic000002)
echo shell_exec("fxtransitions -e swirl -f $frames -d 20 -p 50 $path/pic".str_pad($seq, 6, '0', STR_PAD_LEFT).".jpg $path/pic".str_pad(($seq+1), 6, '0', STR_PAD_LEFT).".jpg $path/fx%06d.jpg");
//here I rename the temporany frames called
//fx000000.jpg to fx000035.jpg for each transition
//to a common index
for($c=0;$c<($frames*2);$c++){
rename("fx".str_pad($c, 6, '0', …Run Code Online (Sandbox Code Playgroud) 我试图将韵律xmpp服务器与我的rails应用程序集成.我需要在注册时在数据库中创建一些用户,这样我才能在韵律服务器中使用它们.
在rails中运行shell命令并输出任何信息日志的最佳方法是什么?
prosodyctl adduser User.username
Run Code Online (Sandbox Code Playgroud) 有时,我会使用 exec()、shell_exec() 和curl_exec()。以下是典型用途。假设其中有 PHP 变量(即第一个变量中的 $html),用户有可能修改其内容。
从安全漏洞的角度来看,我应该关注什么?escapeshellcmd() 和 escapeshellarg() 是答案吗?如果是,应该在哪里使用?
$cmd='echo "html + '.$html.'" | htmldoc --format pdf > '.$filename;
$cmd='/usr/bin/convert '.$docs.' '.$filename;
$cmd='HOME='.$dir.'; /usr/bin/libreoffice3.5 --headless -convert-to pdf --outdir '.$dir.' '.$file_org;
$cmd='wget -O '.$file_org.' "'.$url.'"';
$cmd='/opt/wkhtmltopdf/bin/wkhtmltopdf "'.$url.'" '.$paramaters;
$cmd='/usr/bin/php -q '.$worker.' '.$session_id.' >/dev/null &';
exec($cmd);
$cmd='sendfax -n -m -w -i '.$id.' -o JohnDoe -D -S "hello@gmail.net" -s "us-leg" -f "'.$from.'" -d "'.$to.'" '.$doc_list;
$cmd = "faxstat -s | grep \"^$jid \"";
$output = shell_exec($cmd);
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERAGENT, …Run Code Online (Sandbox Code Playgroud) shell-exec ×8
php ×6
shell ×5
exec ×2
codeigniter ×1
curl ×1
echo ×1
git ×1
imagemagick ×1
java ×1
linux ×1
runtime.exec ×1
security ×1