我正在使用 TCL/Tk 中的文件浏览器,我想添加一些东西来执行当前选择的命令(使用 %l %f) %l 执行完整列表, %f 执行每个文件的命令。我唯一的问题是,如果我输入一个像“gedit”这样的命令,例如它可以工作,但是一旦我输入一个带参数的命令,它就不起作用......我到处找,但我没有得到它。 .. 如果有人可以帮助我... btw getl var Name 是一个函数,它在完整路径 (/home/...) 中返回一个 FileName,如果我返回应该执行的字符串并将其放入终端它工作...
这是代码:
proc tl_exec {liste command } {
#lorsqu'il faut effectué la commande avec la liste en param
if { [string first "%l" $command] > 0} {
foreach v $liste {
lappend args [getl $v Name]
}
set com [string map [list "%l" [join $args " "] ] $command ]
puts $com
set val [exec [split $com " "] ]
} elseif …Run Code Online (Sandbox Code Playgroud) 我正在为学校做一个项目,我不确定我试图解决它的方式是否可行。该项目涉及制作一个程序,分叉出 2 个孩子,然后必须用其他程序替换他们的 pid,并让 2 个孩子通过使用 read() 和 write() 通过管道交谈。
我的问题是使用 execve 并将管道传递给那个孩子。我现在所拥有的是:
父程序 - 分叉并让孩子调用 execve:
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <fcntl.h>
#define BUF_SIZE 16
/* 2 cmd line arguments
1. file already in system (to be copied)
2. file to be created (the copy)
create pipe (for communication) + 2 child processes
first child replace pid with reader
second child with writer
wait for both children to terminate before exiting
*/
int …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个函数,它将使用本机 openssl 为我做一些 RSA 繁重的工作,而不是使用 js RSA 库。目标是
Node 中的子进程模块有一个 exec 命令,但我看不到如何将输入通过管道传输到进程并将其通过管道返回到我的进程。基本上我想执行以下类型的命令,但不必依赖于将内容写入文件(没有检查 openssl 的确切语法)
cat the_binary_file.data | openssl -encrypt -inkey key_file.pem -certin > the_output_stream
Run Code Online (Sandbox Code Playgroud)
我可以通过编写一个临时文件来做到这一点,但如果可能的话,我想避免它。生成子进程允许我访问 stdin/out 但还没有为 exec 找到这个功能。
有没有一种干净的方法可以按照我在这里起草的方式来做到这一点?是否有一些替代方法可以为此使用 openssl,例如,openssl lib 的一些本机绑定,这将允许我在不依赖命令行的情况下执行此操作?
在我的本地机器上,我使用了 exec 命令,如下所示:
if($serverHost == "api.frapi")
{
$phpBianryPath='/Applications/MAMP/bin/php/php5.4.10/bin/php';
}
else
{
$phpBianryPath='/usr/bin/php';
}
$logDir= dirname(__FILE__). '/BackgroundTask';
exec("$phpBianryPath $logDir/notificationCall.php $token >> $logDir/log_file.log 2>&1 &");
Run Code Online (Sandbox Code Playgroud)
它在我的本地机器上运行完美。但是当我将它上传到生产服务器然后尝试使用它时,它会出现如下错误:
sh: /var/www/html/example/src/frapi/custom/Action/BackgroundTask/log_file.log:
Permission denied
Run Code Online (Sandbox Code Playgroud)
请指导我。我不明白为什么它在生产中不起作用?
所以,我在我的 ubuntu 服务器上,想要执行以下命令:
su -c /path/to/command -s /bin/bash -l otheruser
Run Code Online (Sandbox Code Playgroud)
当我在 linux 命令行中键入此命令时,它完美地要求输入其他用户的密码并执行该命令。
但是,当我这样做时
exec("su -c /path/to/command -s /bin/bash -l otheruser");
Run Code Online (Sandbox Code Playgroud)
它什么也不做。我当然还没有为它指定密码,但它并没有真正返回任何可以帮助我解决这个问题的东西。出于测试目的,我已将该命令的权限设置为 777。
有什么建议?
我已经使用 TOAD 一段时间了,但我的部门要求我评估 PL/SQL Developer 作为可能的更改。
我正在尝试在 PL/SQL 开发人员中运行以下内容。它给出了一个错误说:ORA-00900:无效的 SQL 语句
VARIABLE mycur refcursor;
VARIABLE errorseq NUMBER;
VARIABLE errormsg CHAR;
EXEC rums.rums_sp_tv_project_breakdown2(94090,:mycur);
print mycur;
Run Code Online (Sandbox Code Playgroud)
在 TOAD 中,我可以将它放在 SQL 编辑器中,然后按 F5 键以“作为脚本执行”,输出看起来很好。
关于如何做到这一点的任何想法?我看到 PL/SQL Developer 有一个命令窗口,但我不是 SQLPlus 专家(也许是我的问题),也无法让它在命令窗口中运行。
我目前正在清理现有的代码库,遇到了一个涉及 valgrind 的问题,我想修复它,因为它会导致有用的信息丢失。Valgrind 被称为:
/usr/bin/valgrind --leak-check=full -v --log-file=./log/valgrind/valgrind-%p.log --trace-children=yes ./myapp arg1 arg2 >&! $logfile
Run Code Online (Sandbox Code Playgroud)
有问题的程序是一个服务器,它具有内置的重启功能,通过execl().
当服务器重新启动时,到目前为止收集在日志文件中的所有内容 ( ./log/valgrind/valgrind-1234.log) 都会被清除:日志文件的顶部显示了重新启动时传递的参数。在它之前的任何东西(使用 观察到已经存在tail -f)不再存在。
一方面,看看它是如何开始执行的新过程映像是有道理的。另一方面,我并没有在前一个版本上运行 valgrind,只是为了看到它的辛勤工作消失了!
有谁知道一种让 valgrind 附加到自己的日志文件而不是重新启动它们的方法?如果可能的话,我想避免切换到 valgrind 的,--log-socket因为我不想运行另一台服务器:我目前正在打扫房间,增加复杂性与我们现在需要的完全相反。:)
我有多个QDialog窗口。所有窗口都是用exampleWindow->exec(). 这导致当时只有一个窗口打开。
我必须将这些窗口转换为 non-modal dialog window
这是我的项目的示例代码示例。当 exec() 正在使用系统时,系统将进入循环并等待用户在窗口上执行某些操作。
int result = exampleWindow->exec();
if ( exampleWindow== QDialogButtonBox::Ok )
{
exampleWindow->UpdateCalibrationData(&data);
exampleWindow->UpdateFilterData(&filterData);
SetCalibrationStatusToSuccess();
}
Run Code Online (Sandbox Code Playgroud)
但我想把这个转换成这样:
exampleWindow->show();
// and I need to some loop here for the wait answer of dialog
Run Code Online (Sandbox Code Playgroud) 如何在不“等待”结果 exec 返回的情况stdout下将exec命令的“刷新”到我的脚本中stdout?
例如,在以下脚本中,我希望git clone输出立即出现在我的脚本上下文中:
#!/usr/bin/tclsh
# git outputs progress of the clone download but it isn't visible in this script's context. How can I flush it?
exec git clone /path/to/some/repo.git
Run Code Online (Sandbox Code Playgroud)
我猜我需要某种pipe "|"和tee和文件重定向的组合。似乎无法正确理解。
我是 PyQt 的新手,所以当我创建 UI 文件时,我只是复制了一个 Mainwindow (mainfile.ui) 并将其更改为生成另一个 UI 文件 (Intro.ui)。我知道这不是创建 UI 文件的好方法,因为它总是给出错误:object has no attribute 'exec_'.
这是代码:
MainFile = "mainfile.ui"
Ui_MainWindow, QtBaseClass = uic.loadUiType(MainFile)
FileIntro = "Intro.ui"
Ui_WindowIntro,_ = uic.loadUiType(FileIntro)
class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self):
QtWidgets.QMainWindow.__init__(self)
Ui_MainWindow.__init__(self)
self.setupUi(self)
self.ButtonIntro.clicked.connect(self.OpenWindowIntro)
def OpenWindowIntro(self):
s = WindowIntro()
s.show()
s.exec_() #here is the problem.
class WindowIntro(QtWidgets.QMainWindow, Ui_WindowIntro):
def __init__(self):
QtWidgets.QMainWindow.__init__(self)
Ui_WindowIntro.__init__(self)
self.setupUi(self)
#close the window
self.Button2.clicked.connect(self.Close)
def Close(self):
self.close()
if __name__ == "__main__":
app = 0 # if not the core …Run Code Online (Sandbox Code Playgroud)