Getting ^M character added to script when copying files from Windows server to AIX machines

I am not able to get the script executed as script gets automatically added with ^M character at the end of each line.
Please suggest a way to get this fixed. I assume this is happening due to copying of files from Win to AIX machines.

Do you have the dos2unix command available on the AIX endpoint? If yes, you can just call dos2unix yourfile

Alternatives, you can use the sed command to replace the ^M chars
sed "s/^M$//" infile > outfile

Thanks but dos2unix command only works for Linux.
Tried using sed command as well but it is not working via Bigfix script.
Kindly suggest.

Can you post an example of your action script?

// ---------------------------------------------EDITING INSTRUCTIONS---------------------------------------------------------------------
// When editing this task through the Manage Software Distribution Packages dashboard, you will have the option to preserve any custom edits you make to this action.
// If you select the option to preserve custom edits, only areas bound by the comment markers ‘Preparation Marker’, ‘Command Marker’ and ‘Closing Marker’ are updated.
// To ensure that all your custom Action Script changes can be preserved, only make changes to areas that are not bound by the comment markers.
// Removing the comment markers may result in the Action Script not updating correctly during the next edit.
// See KB Article swg21668807 (http://www-01.ibm.com/support/docview.wss?uid=swg21668807) for more information.
// --------------------------------------------------------------------------------------------------------------------------------------

//**Begin Preparation Marker
// Download all specified files
begin prefetch block
add prefetch item name=9665A61BEC31DBF453BCCE39AC49371E564CD92C sha1=9665a61bec31dbf453bcce39ac49371e564cd92c size=507 url=SWDProtocol://127.0.0.1:52311/Uploads/9665A61BEC31DBF453BCCE39AC49371E564CD92C/MQSHC.sh.bfswd sha256=5003f7ceba304ef96a196d54ef941256b7fce3a9be4eaf961548dd1409d29423
add prefetch item name=DF552D7F0B138731F3A60C6E8880C8157A35961B sha1=df552d7f0b138731f3a60c6e8880c8157a35961b size=15033 url=SWDProtocol://127.0.0.1:52311/Uploads/DF552D7F0B138731F3A60C6E8880C8157A35961B/genEAIReports.sh.bfswd sha256=f8ee3b9d4b6913bd2c6a2c02bc5d00a3f42d8a4145263543c736115374d0dfb2
end prefetch block

wait rm -rf "/tmp/TEM"
wait mkdir "/tmp/TEM"
wait mkdir "/tmp/TEM/SCRIPTS"
wait mkdir "/tmp/TEM/RESULTS"
wait mkdir "/tmp/TEM/RESULTS/MQSHC"
wait mkdir “/tmp/TEM/MQSHC_DATA”

// All SWD files will go into a folder in the clients __BESData folder. This folder gets cleared on every restart.
parameter “baseFolder” = “__Download/”
// Move files into subfolders and unescape file names
move “__Download/9665A61BEC31DBF453BCCE39AC49371E564CD92C” "/tmp/TEM/MQSHC_DATA/MQSHC.sh"
move “__Download/DF552D7F0B138731F3A60C6E8880C8157A35961B” “/tmp/TEM/SCRIPTS/genEAIReports.sh”

wait sh /tmp/TEM/SCRIPTS/genEAIReports.sh
wait sh “chmod -R 755 /tmp/TEM/”

Looks like this was generated by the Software Distribution dashboard - maybe you can get IBM Support to take a look and see if its something to be fixed?

But if you really want to get through with replacing the line endings, you could add the following statement into your action script:

wait sh -c "sed 's/\r//' /tmp/infile.sh > /tmp/outfile.sh"

Replace the infile.sh and outfile.sh accordingly.

Also, since this is SWD related, it may be important to follow this guide, especially the Comment Markers section:
http://www-01.ibm.com/support/docview.wss?uid=swg21668807

Thanks !!

Will try and confirm.

@gupnitin,

Here’s a method to strip the dreaded M$ escape characters within BigFix ActionScript.

// Parse out unwanted Micro$oft escape characters
createfile until __END
{concatenation "%0a" of (concatenation "" of substrings separated by "%0d" of (it as string)) of lines of file "/<path>/<your-original-file-name>"}
__END
move __createfile /<path>/<your-new-file-name>

You’ll have to update the new file permissions to be executable.

Hope this helps.

3 Likes