0
我有一组代码,我想依次通过.py文件而不是.bat文件运行,我该怎么做?我有这样做的以下代码:在python中运行批处理文件
#!/usr/bin/python
import sys
import os
bashCommand = "./available_itemsawk.sh"
os.system(bashCommand)
python_command="python run_process.py"
os.system(python_command)
我有两个问题: 1)我有shell脚本(available_itemsawk.sh)如下:
#!/bin/bash
join -1 4 -2 1 -o 1.1,1.2,1.3,1.4,1.5,1.6,2.2 <(sort -k4 abc.txt) <(sort -k1 cdf.txt) > join.txt
awk '{print $1"\t"$2"\t"$3"\t"$4"\t"$5"\t"$6}' join.txt > temp
mv temp join.txt
然而,当我打电话和运行它通过python脚本,我得到以下错误:
sort: write failed: standard output: Broken pipe
sort: write error
2)如何通过os.system进程串行运行脚本?
abc.txt
chr7 99999667 100000138 ENSG00000078487:I17.1 -
chr7 100000139 100000199 ENSG00000078487:E17.1 ENSE00001180416 -
chr9 100000046 100000367 ENSG00000203279:E2.1 ENSE00001678182 -
chr3 99998605 100000561 ENSG00000036054:I5.1 +
chr3 100000562 100000586 ENSG00000036054:E6.1 ENSE00001916783 +
chr3 100000586 100000691 ENSG00000036054:E6.2 ENSE00003639820|ENSE00001916783 +
chr9 99983518 100000704 ENSG00000159712:I1.1 -
chr9 100000368 100000704 ENSG00000203279:I1.1 -
chr9 100000731 100000765 ENSG00000254876:E1.1 ENSE00002183448 +
chr9 100000765 100000779 ENSG00000197816:E1.1 ENSE00003621967 +
cdf.txt
ENSG00000078487:I17.1
ENSG00000254876:E1.1
ENSG00000036054:E6.1
ENSG00000036054:I5.1
ENSG00000197816:E1.1
看起来像在shell脚本本身,独立蟒蛇的错误。你能否确认当你直接执行shell脚本时,它可以工作? –
@quantum_random:它独立运行得很好,而且我使用mac终端作为运行代码的平台。 – AishwaryaKulkarni
您可以给出abc.txt和cdf.txt中内容的示例吗?我可以尝试在我的结尾重现这一点。我正在使用Ubuntu,但它应该没关系。 –