I am trying to run below script which allows redirecting the messages to both terminal and a log file. The script is running fine on linux and Mac systems however it is failing while running as part of an AWS SSM command/document.
SSM Command shell script
---
schemaVersion: "2.2"
description: "List files"
mainSteps:
- action: "aws:runShellScript"
name: "ListInputFiles"
precondition:
StringEquals:
- "platformType"
- "Linux"
inputs:
runCommand:
- "LOG_FILE='${ssmCmdLogFile}'"
- "exec 2> >( tee -a $LOG_FILE ) 3>&1 1>>$LOG_FILE"
Error during SSM command or script execution
/var/lib/amazon/ssm/i-0ad9fa4f86c906342/document/orchestration/012ec968-3045-4aa5-9b1b-264d9a3e9c62/ListInputFiles/_script.sh: line 2: syntax error near unexpected token `>'
/var/lib/amazon/ssm/i-0ad9fa4f86c906342/document/orchestration/012ec968-3045-4aa5-9b1b-264d9a3e9c62/ListInputFiles/_script.sh: line 2: `exec 2> >( tee -a $LOG_FILE ) 3>&1 1>>$LOG_FILE'
failed to run commands: exit status 2
Not sure why this is failing. Please help.