首页 > 编程知识 正文

shell脚本抛出异常,shell运行python脚本

时间:2023-05-04 18:22:41 阅读:16922 作者:1057

如果python脚本在获得异常时返回非零错误级别,则可以使用|| {}记录消息。

./scriptA.py '$file' || {

printf 'npythonscriptscripta.pyfailedwithfile' % s'. n ' $ file ' shell testlog.txt

}

我其实是想先简化你的代码:

#! /zxdbz/bash

yesterday=$ (date-- date ' yesterday ' ' % y % m % d ' ) )

f today=$ (date-- date ' today ' ' % m-% d-% y ' )

year=$(date ' %Y ' )

readarray-t文件列表

for file in '${filesList[@]}; 德奥

printf 'nstartprocessingfile 3360 % sn ' ' $ file ' shell testlog.txt

./scriptA.py '$file' || {

printf 'npythonscriptscripta.pyfailedwithfile' % s'. n ' $ file ' shell testlog.txt

}

printf 'nendprocessingfile 3360 % sn ' ' $ file ' shell testlog.txt

道恩

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。