我正在尝试为Android创建一个只需向SSH服务器发送命令的应用程序.无需响应,我只需要能够发送命令.我想知道是否有任何我可以使用的java库?
不需要高级的东西,只需要一个纯粹的连接来发送命令.
在我的shell脚本中,我的最后一行是:
...
echo "$l" done
done
exit
Run Code Online (Sandbox Code Playgroud)
我将终端首选项设置为"当shell退出时:关闭窗口".在所有其他情况下,当我在"终端"中键入"exit"或"logout"时,窗口关闭,但对于此".command"文件(我可以双击我的shell脚本文件,脚本运行),关闭窗口,而文件的代码显示"退出",屏幕上显示的是:
...
$l done
logout
[Process completed]
Run Code Online (Sandbox Code Playgroud)
......窗户保持打开状态.有谁知道如何运行shell脚本,然后在完成时自动退出终端窗口?
谢谢!
有没有办法从python调用程序而不等待它返回?我创建了一个脚本,将程序复制到目录并运行该程序.但是当我从python调用程序时,python脚本不会退出,直到我启动的程序退出.我试过os.system和Popen.还有另一种方法吗?
添加信息:os.spawnl与os.P_DETACH仍然不起作用; 根据文档,"P_DETACH类似于P_NOWAIT,但新进程与调用进程的控制台分离".但它仍然以某种方式附加到我的调用进程(调用脚本将不会退出,直到任何被调用的可执行文件返回)
程序:
os.system("start test.exe")
print "Done"
Run Code Online (Sandbox Code Playgroud)
执行test.exe后,它会打印Done.但它不会终止脚本的执行(脚本进程仍在运行).尝试用P_DETACH创建一个守护程序线程和Popen,仍然没有去.
我现在正在笔记本电脑上运行Windows,我想将笔记本电脑上的文件上传到我的uni通用服务器,该服务器运行Linux和MacOSX.
所以,我已经使用PuTTy打开了与该服务器的连接.但是我没有尝试使用本网站指导的命令将笔记本电脑上的文件上传到该服务器:http://news.metaparadigma.de/linux-upload-and-download-via-ssh-terminal-226/.似乎它只适用于Linux到Linux机器.它无法识别我输入的Windows路径(即C:\ a.txt).
我怎样才能做到这一点?
我知道在shell中可以做到:
command1; command2
Run Code Online (Sandbox Code Playgroud)
在R怎么样?是否有一些语法可以将两个命令组合到一行上?
但我正在寻找一个代码,允许任何使用我的批处理文件的用户访问我的文档.想法是他们输入3,按回车键,然后程序将打开他们的"我的文档"文件夹.
不幸的是,每个用户都有不同的名称,因此以下命令将不起作用,除非它后面有一个特定的名称.
%SystemRoot%\explorer.exe c:\users\James\My Documents
Run Code Online (Sandbox Code Playgroud)
是否有某种替代"詹姆斯"?普遍命令?
当按钮被禁用时,我希望灰显我的图像(在按钮上).当我在按钮上有文本(没有图像)时,文本显示为灰色(将图像作为按钮内容,它们不会变灰).有没有简单而美丽的方法呢?
这是我的xaml文件:
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ToolBarTray VerticalAlignment="Top" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" IsLocked="true" Grid.Row="0">
<ToolBar Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Band="1" BandIndex="1">
<Button Command="{Binding Button1}" RenderOptions.BitmapScalingMode="NearestNeighbor">
<Button.Content>
<Image Source="open.ico"></Image>
</Button.Content>
</Button>
<Button Command="{Binding Button2}" RenderOptions.BitmapScalingMode="NearestNeighbor">
<Button.Content>
<Image Source="open.ico"></Image>
</Button.Content>
</Button>
</ToolBar>
</ToolBarTray>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
这是我的代码隐藏文件:
public partial class MainWindow : Window
{
private RelayCommand _button1;
private RelayCommand _button2;
public MainWindow()
{
InitializeComponent();
DataContext = this;
}
public ICommand Button1
{
get
{ …Run Code Online (Sandbox Code Playgroud) 只是想知道使用命令行验证已安装的任何grunt模块的当前安装版本的命令是什么.例如
grunt-compass -v
Run Code Online (Sandbox Code Playgroud)
要么
grunt-compass --version
Run Code Online (Sandbox Code Playgroud)
不工作.
我试图在Windows 7的命令提示符下运行命令CP,但我得到:
'cp' is not recognized as an internal or external command, operable program or batch file.
Run Code Online (Sandbox Code Playgroud)
我是否需要安装任何软件才能运行cp命令?
如果是这样的话?
我正在尝试在Jenkins中执行命令shell,我正在使用Windows 7.在控制台输出中,我有这样的:
Building in workspace C:\Program Files (x86)\Jenkins\workspace\test
[test] $ sh -xe C:\Windows\TEMP\hudson6299483223982766034.sh
The system cannot find the file specified
FATAL: L'exécution de la commande a échoué.
java.io.IOException: Cannot run program "sh" (in directory "C:\Program Files (x86)\Jenkins\workspace\test"): CreateProcess error=2, Le fichier spécifié est introuvable
at java.lang.ProcessBuilder.start(Unknown Source)
at hudson.Proc$LocalProc.<init>(Proc.java:244)
at hudson.Proc$LocalProc.<init>(Proc.java:216)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:816)
at hudson.Launcher$ProcStarter.start(Launcher.java:382)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:97)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:66)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.Build$BuildExecution.build(Build.java:205)
at hudson.model.Build$BuildExecution.doRun(Build.java:162)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:537)
at hudson.model.Run.execute(Run.java:1744)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:374)
Caused by: java.io.IOException: …Run Code Online (Sandbox Code Playgroud)