我有一组代码,我想通过.py文件而不是.bat文件按顺序运行,我该怎么办?我有以下代码:
#!/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
答案 0 :(得分:0)
我无法评论(还没有50分),这是我最好的猜测。
这似乎是权限问题。每个脚本(批处理和python)的单独权限,或者您在脚本标题中定义的内容。
当您的批处理文件包含#!/usr/bin/python
#!/bin/bash
这可能不是您问题的核心。但它让我想到,你的.py脚本中的一个可能是由权限低于批处理脚本或者你的.txt文件所需权限的用户拥有或执行的。
我确保您的所有脚本和输入/输出文件都不需要提升权限。您是以用户还是root身份运行它们?这些是可读的,可写的,可由用户执行还是只是root?