【问题标题】:processing data file when a flag file is created创建标志文件时处理数据文件
【发布时间】:2021-11-16 21:38:22
【问题描述】:

我有一个数据文件,当创建标志文件时,数据文件被加密。这是数据文件名 WSPGLOBAL.PAYMENTS.ISO20022_PAIN_01Ver3.66169592.xml 和标志文件名 SendPaysource.66169592 的示例。我希望能够传递标志文件名的数字部分,并且只 gpg 名称中具有该数字值的相应数据文件。

我目前有一个基于通配符执行 gpg 的工作脚本,但可能存在第二个数据文件尚未准备好发送且没有标志文件。

#!/bin/bash

. /pbapps/pbmis/apps/apps_st/appl/APPSpbmis_ennycebs02.env

if [ -e /misc/pbmis/output/SendPaysource.* ];
then
gpg --always-trust --no-tty -se --passphrase xxxxxxxxx -r xxxxx.xxxxx.com  /misc/pbmis/output/WSPGLOBAL.PAYMENTS.ISO20022_PAIN_01Ver3.*.xml

fi

非常感谢任何建议。

【问题讨论】:

  • 你有多少个标志文件?

标签: bash script sunos


【解决方案1】:

据我了解,您只想传递与数据文件相对应的标志文件,前提是它存在,此代码将完成这项工作:

#!/bin/sh
# Change to bash if the .env file has bashisms

. /pbapps/pbmis/apps/apps_st/appl/APPSpbmis_ennycebs02.env

basedir=/misc/pbmis/output

for data in "$basedir/WSPGLOBAL.PAYMENTS.ISO20022_PAIN_01Ver3."*.xml; do
    without_ext="${data%%.xml}" # Remove extension
    flagnum="${without_ext##*.}" # Extract after '.' (Represents the number part)
    flagfile="$basedir/SendPaysource.$flagnum"

    # Check if the corresponding flag file exists
    [ -e "$flagfile" ] && {
        gpg --always-trust --no-tty -se --passphrase xxxxxxxxx -r xxxxx.xxxxx.com "$data"
    }
done

【讨论】:

  • 效果很好。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-08-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-26
相关资源
最近更新 更多