Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^4: Perl script on windows node

by kaka_2 (Acolyte)
on Apr 03, 2012 at 13:31 UTC ( #963243=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Perl script on windows node
in thread Perl script on windows node

Guys. i need further help. As a action i need to run a command. so what i did is added below in the BOLD.

#use 5.010; use strict; my $modified_within = 60 * 2; # 2 minutes my $size_limit = 1024 * 1024 * 2; # 2 MB my $OPCMSG = "C:\Program Files\HP\HP BTO Software\bin\win64\OpC\opc +msg.exe"; my $file = "H:\\Program Data\\HP\\HP BTO Software\\shared\\tmp\\queues +\\MsgQueue"; if ([stat $file]->[9] > time - $modified_within) { if (-s $file > $size_limit) { # print "File is recent, and over size limit"; } else { print "File is recent, but not over size limit"; $OPCMSG a=OM9 o=failover s=normal mag_t="Hello!! I am fine, hope you a +re doing well"; } } else { print "File is not recent"; }
But it return me error saying <c> Bareword found where operator expected at C:\Migration\failover.pl line 17, near "$OPCMSG a" (Missing operator before a?) syntax error at C:\Migration\failover.pl line 17, near "$OPCMSG a" Substitution replacement not terminated at C:\Migration\failover.pl line 17. How can i run this command through script?


Comment on Re^4: Perl script on windows node
Download Code
Re^5: Perl script on windows node
by cdarke (Prior) on Apr 03, 2012 at 15:40 UTC
    It does not like:
    $OPCMSG a=OM9 o=failover s=normal mag_t="Hello!! etc.";
    where did that come from?
Re^5: Perl script on windows node
by marto (Chancellor) on Apr 03, 2012 at 15:48 UTC

    Please don't ignore the formatting guidelines, this obviously looked wrong when you previewed the post. Your code:

    #use 5.010; use strict; use strict; my $modified_within = 60 * 2; # 2 minutes my $size_limit = 1024 * 1024 * 2; # 2 MB my $OPCMSG = "C:\Program Files\HP\HP BTO Software\bin\win64\OpC\opcmsg +.exe"; my $file = "H:\\Program Data\\HP\\HP BTO Software\\shared\\tmp\\queues +\\MsgQueue"; if ([stat $file]->[9] > time - $modified_within){ if (-s $file > $size_limit) { print "File is recent, and over size limit"; } else { print "File is recent, but not over size limit"; $OPCMSG a=OM9 o=failover s=normal mag_t="Hello!! I am fine, ho +pe you are doing well"; } } else { print "File is not recent"; }

    I notice you ignored my previous advice to test that files exist, resulting in "File is not recent" being displayed for non existent files. Where did you copy and past this line from?

    $OPCMSG a=OM9 o=failover s=normal mag_t="Hello!! I am fine, hope you a +re doing well";

    And more to the point what do you expect it to do? A sensible guess would be that you expect to run opsmsg.exe with these arguments, but you've no idea how to do so and expect people to work through your messed up code and work out what you're trying to do. Don't make posts hard to read with regards formatting, and explain exactly what you're trying to achieve. Making people guess what you expect your hard to read code is doing is a bad strategy. Don't copy and paste code you found/were given online without any understanding of what it does.

    To achieve what you want see the example under system. If you're actually interested in learning Perl I suggest you invest the time reading:

      Hi Marto,

      Thanks for the response. I found this forum today only and new to it so i did not get much time go through the formatting guidelines etc.

      That is correct as action i want to run this command which is a application command and it works in this way from command prompt well.

      ANd yes you are right i dont know how to do it on windows. On Unix i can write shell script and the line i added is from the thinking of same but it does not work with perl.

      Thanks for the resources provided to learn perl, for sure i will start learning now.

      This was urgent for me and that was the reason i asked you guys to write codes.

      issue has been fixed now and i can achieve my goal with the help of you guys.

      Thank You. -KAKA-
        I found this forum today only and new to it so i did not get much time go through the formatting guidelines etc.
        This was urgent for me and that was the reason i asked you guys to write codes.

        One of the mantras associated with Perl is "Laziness is a virtue". It doesn't mean what you think. Your activities are a case in point. The lazy approach is to:

        • provide all pertinent information including code, input data and expected output,
        • read the documentation about using the site and posting nodes,
        • correct bad formatting during the preview.

        This would have taken you half an hour instead of two minutes. You would then have received several replies with the information you needed or questions that focused on just the information we needed to help with your problem. Most likely yoou would have had your problem solved within another hour - total time about an hour and a half.

        Contrast that with what actually happened where your "urgent" problem took five times as long to resolve!

        True laziness is hard work

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://963243]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2014-07-13 15:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (250 votes), past polls