我有一个嵌套的存储过程调用
在其中一个存储过程中,我想将结果保存到表变量中,如下所示:
INSERT INTO @myTable
EXEC sp_myStoredProcedure
Run Code Online (Sandbox Code Playgroud)
但是,因为proc.嵌套发生以下错误:INSERT EXEC语句不能嵌套
必须从另一个过程调用该过程,更改此选项不是一个选项.我想尝试使用输出参数,但仍然必须使用Insert into语句进行设置.
将从存储过程调用中检索到的数据保存到变量中的其他选项有哪些?
我正在尝试使用Maven在运行某些集成测试之前启动应用程序.我在Windows上.我的Maven插件配置如下所示:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>start-my-application</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>start_application.bat</executable>
<workingDirectory>./path/to/application</workingDirectory>
</configuration>
</execution>
<executions>
<plugin>
Run Code Online (Sandbox Code Playgroud)
我的批处理文件如下所示:
start myApplication.exe
Run Code Online (Sandbox Code Playgroud)
在隔离运行时,批处理文件会生成一个单独的窗口来运行应用程序并立即返回控制.
但是,从Maven运行时,构建会在继续之前等待单独窗口中的进程完成.这在某种程度上打败了集成测试阶段......
我有什么想法可以在Maven中启动一个真正独立的过程,以便让构建继续与它一起继续吗?
是否可以将exec()作为一个不同的用户运行(在我的盒子上它作为www-data运行).我希望执行一个脚本,该脚本需要访问不属于www-data的文件.
我正在PHP应用程序中执行以下操作:
$source = '/home/user/file.ext';
$output_dir = $this->setOutputString();
chdir('/home/ben/xc/phplib/bgwatcher-2011a/a01/');
exec('php bin/createjob.php $source $output_dir', $output);
return $output[0];
Run Code Online (Sandbox Code Playgroud)
问题是:我可以控制$source,但不是$output_dir,这是一个传统的Windows文件系统,并且路径中有空格.一个例子$output_dir是:
/home/vol1/district id/store id/this_is_the_file.html
Run Code Online (Sandbox Code Playgroud)
将输出字符串插入exec()函数时,我尝试了两种方法:
addslashes($output_dir)并'"' . $output_dir . '"'转义整个输出字符串.在第一种情况下,路径连接到:
/home/vol1/districtthis_is_the_file.html
...第一个空格和文件名之间的所有内容都被删除了.在第二种情况下,exec()似乎扔鞋并且没有正确执行 - 不幸的是,错误信息在机器中丢失 - 我可以提供它,如果它是绝对必要的,但我也在时间限制下找到解决方案.
这是什么解决方案?我sprintf()是整个字符串exec()吗?我很困惑为什么addslashes不能正常工作以逃避空间,我认为它与exec()的清理有关,但我找不到任何备份它的文档.
更新:我已经尝试了escapeshellarg()和preg_replace()但没有成功.进一步思考这个问题,我是否需要双重逃避这条道路?还是逃避路径和命令?如果路径被exec()取消一次,并且在执行命令之前由PHP取消一次,那么我是否需要考虑这两个转义?或者这不是它的工作原理吗?
如何才能像的git命令git add .,并git commit -m使用PHP来执行?
它是为一个项目创建一个集中的存储库设施来维护学术项目.
exec()似乎没有用.
<?php
$path = "/var/www/repos/$_POST[project]";
$a='';
chdir($path);
exec("git add .");
exec("git commit -m'message'");
echo "<h3 align = center> Succesfully commited all the files.</h3>";
?>
Run Code Online (Sandbox Code Playgroud) 我想知道两个exec函数之间是否存在不同的原因const,如果这只是Single Unix Spec中的一个错误:
摘自Linux手册页,它似乎与Single Unix Specification一致,这里有两个版本exec:
int execlp(const char *file, const char *arg, ...);
int execvp(const char *file, char *const argv[]);
execlp将其参数视为const char *,并且它需要两个或更多.const在C中是一个承诺,函数不会改变指向的数据,在这种情况下是char构成字符串的实际字符().
execvp而是将其参数作为指针数组.但是,不是指向const char *你想要的指针数组,const关键字在不同的位置 - 这对C execvp来说很重要,它说它可能会修改字符串中的字符,但它承诺不会修改数组 - 即指向字符串的指针.所以,换句话说,
int fake_execvp(const char *file, char *const argv[]) {
argv[0] = "some other string"; /* this is an error */
argv[0][0] = 'f'; …Run Code Online (Sandbox Code Playgroud) 我正在使用带有以下命令的Exec Maven插件:
mvn exec:java
我没有设法用这种执行模式设置工作目录.我想使用mainClass(在特定的包中),我希望我的执行的根文件夹在$ {basedir}之外的另一个目录中.
谢谢您的帮助.
我的pom.xml目标<workingDirectory>对我不起作用:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<workingDirectory>${project.build.directory}\classes</workingDirectory>
<mainClass>com.package.MyMainClass</mainClass>
<includeProjectDependencies>true</includeProjectDependencies>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
使用-X选项的结果
[DEBUG] Configuring mojo org.codehaus.mojo:exec-maven-plugin:1.3.2:java from plugin realm ClassRealm[plugin>org.codehaus.mojo:exec-maven-plugin:1.3.2,parent: sun.misc.Launcher$AppClassLoader@11b86e7]
[DEBUG] Configuring mojo 'org.codehaus.mojo:exec-maven-plugin:1.3.2:java' with basic configurator -->
[DEBUG] (f) arguments = []
[DEBUG] (f) classpathScope = runtime
[DEBUG] (f) cleanupDaemonThreads = true
[DEBUG] (f) daemonThreadJoinTimeout = 15000
[DEBUG] (f) includePluginDependencies = false
[DEBUG] (f) includeProjectDependencies = true
[DEBUG] (f) keepAlive = false
[DEBUG] (f) killAfter = 1 …Run Code Online (Sandbox Code Playgroud) 这似乎很容易,之前可能会被问过,但我无法通过搜索找到它.
我安装了几种口味R.我只是想知道,当我运行RStudio时,R它指向的是哪种味道.所以,我需要一个命令 - 理想情况下在RStudio本身 - 可以告诉我R正在使用的这个RStudio窗口的底层可执行文件.
为了清楚起见,我不需要/想要知道我正在使用的R 的版本(例如R version 3.2.2 (2015-08-14) -- 'Fire Safety').相反,我想知道RStudio用来到R的实际路径 - 从RStudio中查看它 - 所以我知道"for reals"它正在使用哪个版本.(例如,/usr/local/bin/R.)
这里有很多很棒的讨论,有些是特定于操作系统的.我有一台Mac.就我而言,我发现:
> system("type R")
R is /usr/local/bin/R
> R.home()
[1] "/usr/local/Cellar/r/3.2.2_1/R.framework/Resources"
> file.path(R.home("bin"), "R")
[1] "/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/bin/R"
Run Code Online (Sandbox Code Playgroud)
正如你所熟悉的那些,我正在使用brew.如果我/usr/local/bin/R在R外寻找,我看到:
$ ls -l /usr/local/bin/R
lrwxr-xr-x 1 mike admin 25 Nov 14 17:31 /usr/local/bin/R -> ../Cellar/r/3.2.2_1/bin/R
Run Code Online (Sandbox Code Playgroud)
最终解决(2个符号链接):
/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/bin/R
Run Code Online (Sandbox Code Playgroud)
作为最终目的地.
所以在我的系统(Mac OS X)上,file.path(R.home("bin"), "R")是最准确的.
我写了一个小的PHP脚本来控制alsa本地机器的音量:
<?php
# for simplicity and testing it really just executes the command:
echo exec('amixer set Master 5%+') . " \n";
Run Code Online (Sandbox Code Playgroud)
现在,当我在命令行上运行此脚本时,它工作正常:
$ php volume.php
Front Right: Playback 39226 [60%] [on]
$ php volume.php
Front Right: Playback 42503 [65%] [on]
$ php volume.php
Front Right: Playback 45780 [70%] [on]
Run Code Online (Sandbox Code Playgroud)
我有音乐播放,我听到声音越来越大.
但是当我尝试从浏览器通过apache运行脚本时调用http://localhost/volume.php它不起作用.
# http://localhost/volume.php
Front Right: Playback 55709 [10%] [on]
# F5
Front Right: Playback 55709 [15%] [on]
# F5
Front Right: Playback 55709 [20%] [on]
Run Code Online (Sandbox Code Playgroud)
现在我听说音量没有变化,百分比似乎与当前状态无关.当它真的仍然是70%时,它说10% - 15% …
我已经在带有apache的freebsd-server上安装了libreoffice headless,以便以编程方式转换文档(例如odt-> pdf).它从命令行工作!但我的目标是能够从PHP做到这一点.这要求web用户(www)可以运行libreoffice.但它不能.
当我自己的用户运行libreoffice时,我得到:
%libreoffice --headless -convert-to pdf Litteraturundervisningogit.doc
javaPathHelper: not found #This should not be a problem, says people on the net.
convert /usr/home/bundsgaard.net/www/jeppe/foredrag/Litteraturundervisningogit.doc ->
/usr/home/bundsgaard.net/www/jeppe/foredrag/Litteraturundervisningogit.pdf using writer_pdf_Export
%
Run Code Online (Sandbox Code Playgroud)
如果我尝试与root相同的命令,它不起作用.同样是来自php的www-user的问题:
sp# libreoffice --headless -convert-to pdf Litteraturundervisningogit.doc
javaPathHelper: not found
sp#
Run Code Online (Sandbox Code Playgroud)
问题是我没有从libreoffice获得任何信息,因此我不知道为什么libreoffice不想像其他用户那样运行.
我的问题是:如何通过php中的exec()授予www-user权限来运行libreoffice?