21 ssh unix command-line putty
我使用以下命令自动登录到远程服务器,然后运行 a 中列出的命令commands.txt,如下所示:
C:\path\to\putty.exe -load "[Sessionname]" -l [user] -pw [password] -m C:\path\to\commands.txt
Run Code Online (Sandbox Code Playgroud)
commands.txt 包含以下内容:
ps -elf|grep 'sometext'
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试这样做时,会出现一个 PuTTY 的新窗口,但它会在登录后立即关闭并退出。结果,我看不到命令的输出。
我不明白这里发生了什么。我的方法错了还是我需要采取更多步骤使 PuTTY 窗口在退出之前暂停一段时间?
小智 12
首先,您需要创建一个单独的文件,其中包含要执行的所有命令。
示例:我想使用 PuTTY 在我的域上下载和安装Drupal。为此,您必须:
首先创建一个 .txt 文件。在该文件中是命令。我的是:“ drush dl drupal ”下一行,“ drush si --account-name=[account name] --account-pass=[account pass] --db-url=mysql://[user]:[pass ]@localhost/[数据库名称] --y "
保存该文件后,您现在将创建一个BAT文件或在 CMD 提示符中键入:
putty.exe -ssh [domain name] -l [username] -pw [password] -m [the directory of the .txt file you created which contains the codes you want to be executed]Avi*_*gal 11
您应该使用plink.exe(PuTTY 后端的命令行界面)而不是putty.exe
您可以从PuTTY 下载页面获得
没有链接:
似乎唯一的方法是使用-log <logfile>选项,然后打印其内容并删除它。