richsark
asked on
Convert this Windows script to a perl script so I can use it on Macbook
Hey there... I have a script that I used in cygwin:
I need to somehow convert it to perl script that I can run on my macbook
Thanks!
#!/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 #####
I need to somehow convert it to perl script that I can run on my macbook
Thanks!
ASKER
I did that but it does not run as is.
I think I may need to replace the line:
from
wget --no-check-certificate https://${GM}/api/dist/CPAN/authors /id/SHARK
to:
curl --insecure https://${GM}/api/dist/CPAN/authors /id/SHARK
Is there a way not to use bash and use perl. so all I need to do is run it as:
./upgrade-API.pl
I think I may need to replace the line:
from
wget --no-check-certificate https://${GM}/api/dist/CPAN/authors
to:
curl --insecure https://${GM}/api/dist/CPAN/authors
Is there a way not to use bash and use perl. so all I need to do is run it as:
./upgrade-API.pl
ASKER
This is what I get:
richards-macbook-air|richs ark_air$ ./update-api.sh 192.168.0.222
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://192.168.0.222/api/dist/CPAN/authors/id/SHARK/">here</a>.</p>
</body></html>
cat: SHARK: No such file or directory
tar: Option f requires an argument
Usage:
List: tar -tf <archive-filename>
Extract: tar -xf <archive-filename>
Create: tar -cf <archive-filename> [filenames...]
Help: tar --help
usage: mv [-f | -i | -n] [-v] source target
mv [-f | -i | -n] [-v] source ... directory
/Users/richsark_air
Can't open perl script "./Makefile.PL": No such file or directory
make: *** No targets specified and no makefile found. Stop.
make: *** No rule to make target `test'. Stop.
make: *** No rule to make target `install'. Stop.
richards-macbook-air|richs ark_air$
richards-macbook-air|richs
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://192.168.0.222/api/dist/CPAN/authors/id/SHARK/">here</a>.</p>
</body></html>
cat: SHARK: No such file or directory
tar: Option f requires an argument
Usage:
List: tar -tf <archive-filename>
Extract: tar -xf <archive-filename>
Create: tar -cf <archive-filename> [filenames...]
Help: tar --help
usage: mv [-f | -i | -n] [-v] source target
mv [-f | -i | -n] [-v] source ... directory
/Users/richsark_air
Can't open perl script "./Makefile.PL": No such file or directory
make: *** No targets specified and no makefile found. Stop.
make: *** No rule to make target `test'. Stop.
make: *** No rule to make target `install'. Stop.
richards-macbook-air|richs
ASKER
I tried macports but it hangs on installing.
richsark
Aug 28, 2012 12:02 AM
I have a new 2012 2 gen MBA. 256 SSD 8GB i7
Trying to install
port -d install gmake
Its been hanging on this section for 4 hours now...
checking how to run the C preprocessor... /usr/bin/clang -E
checking for grep that handles long lines and -e... (cached) /usr/bin/grep
checking for egrep... /usr/bin/grep -E
There is an issue I think for mountain lion from what I seen.
As a work around can this one I have be reformatted to run on my Mac please.
richsark
Aug 28, 2012 12:02 AM
I have a new 2012 2 gen MBA. 256 SSD 8GB i7
Trying to install
port -d install gmake
Its been hanging on this section for 4 hours now...
checking how to run the C preprocessor... /usr/bin/clang -E
checking for grep that handles long lines and -e... (cached) /usr/bin/grep
checking for egrep... /usr/bin/grep -E
There is an issue I think for mountain lion from what I seen.
As a work around can this one I have be reformatted to run on my Mac please.
Personally i'd perseveer with getting a local variant of wget, e.g. via homebrew e.g.
but if you want to go down the curl route you'll need to tell curl to follow the 301 redirect (which it won't do by default, unlike wget) e.g.
ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go)
...
brew install wget
but if you want to go down the curl route you'll need to tell curl to follow the 301 redirect (which it won't do by default, unlike wget) e.g.
curl -kLOs https://${GM}/api/dist/CPAN/authors/id/SHARK
ASKER
ok, can we take it from the top as its may be easier for me and anyone else who wants to help :)
I like to run this script as update-api.pl 100.100.100.1 (( the IP adress of where its at. it could be different other time ))
what I need for it to do it like so:
1st:
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
Then:
Look the for tar.gz it downloaded "shark.ar.gz"
unpack it
then run these
cd $PDIR
pwd
/usr/bin/perl /Makefile.PL
/usr/bin/make
/usr/bin/make test
/usr/bin/make install
cd ..
no-check-certificate https://${GM}/api/dist/CPAN/authors /id/SHARK
I like to run this script as update-api.pl 100.100.100.1 (( the IP adress of where its at. it could be different other time ))
what I need for it to do it like so:
1st:
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
Then:
Look the for tar.gz it downloaded "shark.ar.gz"
unpack it
then run these
cd $PDIR
pwd
/usr/bin/perl /Makefile.PL
/usr/bin/make
/usr/bin/make test
/usr/bin/make install
cd ..
no-check-certificate https://${GM}/api/dist/CPAN/authors
It's not clear to me if you already know the full path of the file you need to download, or if you first need to parse an html page to get the path.
Is it necessary for you to use --no-check-certificate? If not, then I'd use the LWP::Simple module to retrieve the file instead of wget. If you do need that option, then I'd switch to LWP::Curl which supports that option and follows redirects.
Is it necessary for you to use --no-check-certificate? If not, then I'd use the LWP::Simple module to retrieve the file instead of wget. If you do need that option, then I'd switch to LWP::Curl which supports that option and follows redirects.
ASKER
Hi Fishmonger.. so assume I get LWP for my mac. What changes below do you think I need to make?
#!/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 #####
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thread closed
On the shell, try command:
which bash
If you see response, all you need to do is to adjust paths accordingly