标签: remote-execution

ssh 远程命令未按预期工作(读取问题)

我的服务器上有一个名为test.sh

#!/bin/bash
read -p "Select an option [1-4]: " option
echo "You have selected $option"
Run Code Online (Sandbox Code Playgroud)

当我通过 ssh 手动运行它时,我看到:

me@me:~$ ssh root@server
root@server's password:
[...]
root@server:~# bash test.sh
Select an option [1-4]: 48
You have selected 48
Run Code Online (Sandbox Code Playgroud)

当我作为 ssh 远程命令运行它时,我看到以下内容:

me@me:~$ ssh root@server 'bash test.sh'
root@server's password: 
48
You have selected 48
Run Code Online (Sandbox Code Playgroud)

我对此输出不满意,因为它缺少Select an option [1-4]:提示字符串和我从中派生的原始脚本test.sh包含很多这样的交互式对话字符串,我需要它们全部。

我知道会read打印它的提示,stderr因此我尝试使用以下命令启动脚本,以防省略 stderr,但输出仍保持不变:

ssh root@server 'bash test.sh >&2'
ssh root@server 'bash test.sh' >&2
ssh root@server 'bash …
Run Code Online (Sandbox Code Playgroud)

linux ssh bash remote-execution

4
推荐指数
1
解决办法
5796
查看次数

从另一个 python 文件执行 selenium 测试用例

我正在尝试从 python 文件执行 selenium 测试用例。我知道可以使用 python 的子进程模块来完成 - 但我想探索调用测试用例函数的可能性。

这是我的代码

chrome_settings_test.py

from selenium import w ebdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
import unittest, time, re
import os, shutil, sys

from selenium.webdriver.chrome.options import Options
from selenium import webdriver

class SeleniumException(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome()
        self.driver.implicitly_wait(30)


    #self.driver = nested_selenium.driver
        self.base_url = "https://www.google.co.in/"
        self.verificationErrors = []

    def test_selenium_exception(self):
        driver = self.driver
        driver.get(self.base_url + "/")
        driver.find_element_by_id("gbqfq").clear()
        driver.find_element_by_id("gbqfq").send_keys("Check this out")

    def is_element_present(self, how, what):
        try: self.driver.find_element(by=how, value=what) …
Run Code Online (Sandbox Code Playgroud)

python selenium remote-execution selenium-webdriver

3
推荐指数
1
解决办法
2954
查看次数

在 Powershell 中展开通过单引号存储的字符串变量

我有一个场景,我需要将 powershell 路径构建为$RemotePath = '$($env:USERPROFILE)\Desktop\Shell.lnk'. 这个变量被传递到需要执行的远程机器。远程机器将其作为字符串变量接收。如何扩展要评估的字符串$env:USERPROFILE

powershell remote-execution variable-expansion

3
推荐指数
1
解决办法
2630
查看次数

如何将参数传递到Powershell脚本并在远程计算机上运行

我试图将2个参数传递给PS脚本,该脚本将修补远程计算机上的SQL Server。这是我使用的代码:

$Patcher = "\\remoteShareLocation\SQLpatcher.ps1"
$ver = "SQL2012"
$inst = "NEWINST"

Invoke-Command -ComputerName RMTMACHINE -credential dmn\usrname -ScriptBlock {$Patcher $ver $inst}
Run Code Online (Sandbox Code Playgroud)

这会要求提供凭据,但不会运行,也不会显示任何输出。语法有什么问题吗?还有其他替代cmdlet吗?

powershell remote-execution

0
推荐指数
1
解决办法
2362
查看次数