Good afternoon to you all
I really need your help
I have the following script developed in .sh and I need to convert it into perl. Can someone help me do it please?
Here�s the script:
##############################################
##############################################
cat /var/www/monitor/scripts/TestProbes/probelist.txt | while read probe
do
{
perl /var/www/monitor/scripts/slabb/getQosData.pl -s DNS -m Availability -c $probe
} >> /var/www/monitor/scripts/TestProbes/Probes/"$probe".txt
if [[ -s /var/www/monitor/scripts/TestProbes/Probes/"$probe".txt ]] ; then
echo "Probe has data"
else
echo "Probe has no data"
fi
rm /var/www/monitor/scripts/TestProbes/Probes/"$probe".txt
touch /var/www/monitor/scripts/TestProbes/Probes/"$probe".txt
chmod 777 /var/www/monitor/scripts/TestProbes/Probes/"$probe".txt
done
############################################
Scott
2
Why?
All you are doing is running basic commands - half of which I can't understand what or why.
What will perl give you here?
zarahel
3
I need to integrate it on an application that only interprets perl.
The script is very simple as you said. It�s only a condition checking if a specific file is empty or not. I just want to convert it into perl.
---------- Post updated 10-16-09 at 11:15 AM ---------- Previous update was 10-15-09 at 04:02 PM ----------
Anyone?
Few thing that you can start with to convert this into perl -
1) File opening /Reading from file/Writing to a file/Executing a script
2) Condition checking (file exist ?)
You can open the file for reading in perl using
open(FHI,"</var/www/monitor/scripts/TestProbes/probelist.txt");
You can read data from this file (alternate of while read line in unix)
while(defined(<FH>))
{
}
How you will execute the perl script in side it ?
system(/var/www/monitor/scripts/slabb/getQosData.pl -s DNS -m Availability -c $probe);
How you will write the contents to a file $probe.txt ??
open(FHO,">/var/www/monitor/scripts/TestProbes/Probes/$probe.'.txt'");
You can check the file exist or not using
if (- e $probe)
{
print "Probe exist\n";
}
else
{
print "Probe missing \n";
}
---Just assemble this idea into your perl script --