Command failed (Substitution failed while writing file) createfile until __EOF

Script runs on RedHat 6 natively fine. I add the script to Fixlet action. The client log file shows Command failed (Substitution failed while writing file) createfile until __EOF (action:1788) from log file. The scrip is

// Enter your action script here
createfile until __EOF
#!/bin/bash

get mini UID limit

l=$(grep “^UID_MIN” /etc/login.defs)

get max UID limit

l1=$(grep “^UID_MAX” /etc/login.defs)

use awk to print if UID >= $MIN and UID <= $MAX

awk -F’:’ -v “min=${l##UID_MIN}” -v “max=${l1##UID_MAX}” ‘{ if ( $3 >= min && $3 <= max ) print $0}’ /etc/passwd > /var/opt/BESClient/localusers.tx
__EOF
move __createfile listAdminUsers.sh
move chmond a+x listAdminUsers.sh
wait listAdminUsers.sh

The script executes and creates file __createfile and writes out all lines until awk -F’:’ -v “min=${l##UID_MIN}” -v “max=${l1##UID_MAX}” ‘{ if ( $3 >= min && $3 <= max ) print $0}’ /etc/passwd > /var/opt/BESClient/localusers.tx

What is in the that line that is causing the problem? the /etc/login.defs and /etc/passwd files exist. the script runs on the system. Any thoughts?

The braces in your actionscript for awk are being interpreted by the BigFix Client for embedded relevance, and they need to be escaped. See this technote:

http://www-01.ibm.com/support/docview.wss?uid=swg21506259

1 Like

Thank Jeremy , that solved that part of the script and I am almost there. The script I am using now is

//Shell to Action Script Conversion Utility
delete __appendfile

appendfile #!/bin/bash
appendfile
appendfile ## get mini UID limit ##
appendfile l=$(grep “^UID_MIN” /etc/login.defs)
appendfile
appendfile ## get max UID limit ##
appendfile l1=$(grep “^UID_MAX” /etc/login.defs)
appendfile
appendfile ## use awk to print if UID >= $MIN and UID <= $MAX ##
appendfile awk -F’:’ -v “min=${{l##UID_MIN}” -v “max=${{l1##UID_MAX}” '{{ if ( $3 >= min && $3 <= max ) print $0}'
appendfile /etc/passwd > /var/opt/BESClient/localusers.tx

//modify appendfile to allow execution
wait chmod 555 “{(client folder of current site as string) & “/__appendfile”}”

//execute shell script as written
wait “{(client folder of current site as string) & “/__appendfile”}”

Which now works up to the last line which executes the script. The file localusers.tx is created by empty. I get a error code 126. I am running this on my redhat 6 system.

any thoughts.

I solved the execute issue and it is now working. Thanks for the escape information.

2 Likes