我尝试过各种方法将stdout和stderr重定向到/dev/null,但没有成功。我几乎有我的整个生命运行bash,我从来没有遇到过这个问题,但第一次在BSD,我被困在/bin/sh。
我试过的是:
if ls ./python* 2> /dev/null; then
echo found Python
fi
..。如果Python不存在,它将静音来自ls的错误消息。但是,如果存在python.tgz,则输出如下所示的一行:
# ./test.sh
./python-2.7.3p1.tgz
我试过:
if ls ./python* &> /dev/null; th
如何将Windows中的所有流量重定向到vidalia?我尝试使用Proxifier,但它似乎只重定向选定的应用程序?但我需要重定向所有传出流量示例:
redirect all traffic from cmd.exe ping www.host.com;
redirect all traffic from cmd.exe d:\python\python.exe inet.py -url "www.host.com"
和数据包通过TOR。
当我在Linux机器上运行python3解释器并试图重定向像这样的文件是stdout时,什么都不会发生:
user@workmachine:~$ python3 > python.txt
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
\>>>
文件python.
我有以下程序来测试Python中的输入重定向。
a = int(raw_input("Enter a number: "))
b = raw_input("Enter a string: ")
print "number entered = ", a
print "string entered = ", b
如果我没有重定向就运行这个程序,输入和输出如下所示:
Enter a number: 100
Enter a string: sample
number entered = 100
string entered = sam
我有一个python脚本,它将调用nmake。我想在powershell中调用这个脚本,如下所示。
python D:\build.py -f folder
它工作正常,输出如下:
Microsoft (R) Program Maintenance Utility Version 11.00.50727.1
Copyright (C) Microsoft Corporation. All rights reserved.
但是,如果我添加重定向,使所有stderr&stdout都转到build.log,如下所示,它会显示红色错误:
python D:\build.py -f fold