Convert this Windows script so I can use it on Macbook

Hi guys,

I am been banging my head for days on something that appears too simple to be so hard for me.

I have this bash script which I used just fine on my windows PC.

I took this file over to my Macbook and try to run it and it fails like no tomorrow.

This is the contents of the file:

#!/bin/bash
 
GM=$1
 
 
if [ "$1" == "-h" -o "$1" == "--help" -o "$#" -ne 1 ] ; then
  echo "$0 <GM_IPaddr> "
  echo " Provide the IP address of the Grid Master as the one argument to this command"
  exit 1
fi
 
 
wget --no-check-certificate https://${GM}/api/dist/CPA<wbr ></wbr>N/authors/<wbr ></wbr>id/SHARK
 
PerlPkg=`cat SHARK| grep "tar.gz" | awk -F'"' '{print $2}'`
PDIR=`echo $PerlPkg | sed 's/.tar.gz//'`
 
wget --no-check-certificate https://${GM}/api/dist/CPA<wbr ></wbr>N/authors/<wbr ></wbr>id/SHARK/$<wbr ></wbr>{PerlPkg}
 
tar xzvf $PerlPkg
 
mv $PerlPkg $PDIR
 
rm -f SHARK
 
cd $PDIR
   pwd
   /usr/bin/perl ./Makefile.PL
   /usr/bin/make
   /usr/bin/make test
   /usr/bin/make install
cd ..
 
##### End Script #####

Would someone be so kind into converting this so I can run it on my Macbook.

I may be wrong....
I think Mountain Lion using curl options using that URL bombs out until i am able to download a file named "SHARK"

Other errors seem to be due to MacOS being picky about arguments.

For example, it looks like it require the 'dash' prefix to the tar arguments, whereas any other normal Unix system does not.

Thank you in advance !

If you have error messages, please run the script with set -x tracing so others can see the commands execute and the resultant error messages.

If you wrote it up in Microsoft Notepad, it will be full of carriage returns which will cause it to fail.

tr -d '\r' < wingarbage > fixedfile
1 Like

Further to @Corona688's excellent post.

Please post the output of the following command which is designed to make control characters visible in a suspect script:

sed -n l scriptname