我正在尝试通过我的本地网络访问在端口8080上运行的jenkins服务,但由于某种原因它不允许我连接.我可以远程进入pi并启动一个Web浏览器并输入localhost:8080,它工作正常.
这是raspbian的简单安装,我没有安装防火墙,所以不知道为什么我无法访问本地网络上的jenkins.
我在另一个Stack Overflow问题上找到了关于如何在命令行上从Python文件中调用特定函数def 的答案,但是调用的函数不带任何参数:
$ python -c 'from foo import hello; print hello()'
Run Code Online (Sandbox Code Playgroud)
(我删除了print语句,因为它对我的需求似乎是多余的,在这种情况下我只是调用函数.)
有几个答案说使用参数解析,但这需要更改已经存在的几个文件,这是不可取的.
关于该问题的最后一个答案介绍了如何在Bash中做我想要的事情(我需要知道如何在PowerShell中完成它).
$ ip='"hi"' ; fun_name='call_from_terminal'
$ python -c "import ${fun_name} as cft; cft.test_term_fun(${ip})"
hi
Run Code Online (Sandbox Code Playgroud)
这是我的Python代码:
def operator (string):
print("Operator here, I got your message: ", string)
Run Code Online (Sandbox Code Playgroud)
从PowerShell我想称之为:
$ python -c 'from myfile import operator; operator("my message here")'
Run Code Online (Sandbox Code Playgroud)
我在PowerShell中输入的文字命令:
python -c 'from testscript import operator; operator("test")'
Run Code Online (Sandbox Code Playgroud)
我正在回复的文字错误消息:
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'test' is not defined
Run Code Online (Sandbox Code Playgroud) Powershell突然从cmd和powershell提示中退出打开。在它工作时和退出工作之间,我尚未安装任何新产品。
当我尝试使用以下命令从cmd窗口(提升和不提升)启动powershell.exe时
C:\Users\myuser>powershell.exe
Run Code Online (Sandbox Code Playgroud)
我从操作系统中收到一个弹出错误,提示:
This app can't run on your PC
Run Code Online (Sandbox Code Playgroud)
关闭该弹出窗口后,我会从cmd提示进行呼叫,然后打印:
Access is denied
Run Code Online (Sandbox Code Playgroud)
到屏幕上(是的,即使我在提升的cmd提示符下执行此操作)
当我尝试使用以下命令在powershell中执行此操作时:
PS C:\Users\myuser> powershell.exe
Run Code Online (Sandbox Code Playgroud)
我得到:
Program 'powershell.exe' failed to run: The specified executable is not a valid application for this OS platform.
At line:1 char:1
+ powershell.exe
+ ~~~~~~~~~~~~~~.
At line:1 char:1
+ powershell.exe
+ ~~~~~~~~~~~~~~.
+ CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException
+ FullyQualifiedErrorID : NativeCommandFailed
Run Code Online (Sandbox Code Playgroud)
显然,甚至powershell不再喜欢powershell。
我曾尝试重新启动计算机,但仍无法解决问题,但我完全受其下一步的困扰。
powershell ×2
command-line ×1
function ×1
jenkins ×1
networking ×1
port ×1
python ×1
raspberry-pi ×1
raspbian ×1
windows ×1