Jef*_*zel 8 python unix bash shell
我编写了一个正在执行我想要它的bash脚本,但是却出现了以下错误:
close failed in file object destructor: sys.excepthook is missing lost sys.stderr
我完全不知道如何解决这个问题.这是脚本:
#!/bin/bash
usage () { echo "${0##*/} inputfile outputfile"; exit 1; }
(($#==2)) || usage
INPUTFILE="$1"
OUTPUTFILE="$2"
# All that is written between between the 'cat' command and
#+ 'EOF' will be sent to the output file.
cat <<EOF >$OUTPUTFILE
$(date "+Generated on %m/%d/%y at %H:%M:%S")
DATA AUDIT: $1
------------
COLUMN NAMES
------------
$(csvcut -n $INPUTFILE)
---------------------------------------
FIRST TEN ROWS OF FIRST FIVE COLUMNS
---------------------------------------
$(csvcut -c 1,2,3,4,5 $INPUTFILE | head -n 10)
------------
COLUMN STATS
------------
$(csvcut $INPUTFILE | csvstat )
---END AUDIT
EOF
echo "Audited!"
Run Code Online (Sandbox Code Playgroud)
我是shell脚本的新手,也是python的新手.我将不胜感激任何帮助.
Geo*_*rge 19
将Python 2.6.2脚本的输出管道输入到Ubuntu 9.04上的head命令时,我看到了这个错误bash.我加了try块关闭stdout并stderr退出脚本之前:
try:
sys.stdout.close()
except:
pass
try:
sys.stderr.close()
except:
pass
Run Code Online (Sandbox Code Playgroud)
我不再看到错误.