我编写了一个python脚本,从列表中读取文件偏移量和文件名,并将一个大文件分成多个文件。对于拆分,我使用shell脚本,它将这些名称和偏移量作为输入,并使用head命令创建多个输出文件。我使用python将输入发送到shell脚本。这在我的Windows7和其他Linux系统中运行良好。但是,当我试图在esx6.5hypervisor上使用相同的脚本时,我意识到我不能在esx6.5中使用相同的shell脚本,因为head command不能像在其他操作系统中那样工作。在
list=['IdleChk_1_E1.txt','749','IdleChk_2_E1.txt','749','reg_fifo_E1.txt','5922','igu_fifo_E1.txt','161','protection_override_E1.txt','1904','fw_asserts_E1.txt','708','McpTrace.txt文件'15578','物理_转储.txt','129','GrcDumpE1.bin','3629656']
偶数元素是文件名,奇数元素是大小。在
下面是我用来向shell脚本发送输入的命令:Process_three=subprocess.Popen("./read.sh %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s" \
%(''.join(map(str, list_info[1:2])), ''.join(map(str, list_info[0:1])),\
''.join(map(str, list_info[3:4])), ''.join(map(str, list_info[2:3])),\
''.join(map(str, list_info[5:6])), ''.join(map(str, list_info[4:5])),\
''.join(map(str, list_info[7:8])), ''.join(map(str, list_info[6:7])),\
''.join(map(str, list_info[9:10])), ''.join(map(str, list_info[8:9])),\
''.join(map(str, list_info[11:12])), ''.join(map(str, list_info[10:11])),\
''.join(map(str, list_info[13:14])), ''.join(map(str, list_info[12:13])),\
''.join(map(str, list_info[15:16])), ''.join(map(str, list_info[14:15])),\
''.join(map(str, list_info[17:18])), ''.join(map(str, list_info[16:17])),\
file_name), stdout=subprocess.PIPE, shell=True)
(temp, error) = Process_three.communicate()
这是我的shell脚本。在
^{pr2}$
在ESX中,只有第一个头命令输出有效。在
有没有其他方法分割文件。我知道有split命令,但是这个命令将文件分成两半。我需要动态大小的文件。
我希望我能从python中分离出来。顺便说一下,我是Python新手。在