in reply to Re: How to call cmd line within PERL?
in thread [Newbie Question] How to call cmd line within PERL?

Thanks.
(ps. The Tiny link was broken so I looked into http://perldoc.net/Capture/Tiny.pod hoping that's what you meant to refer)

I maybe a bit lost honestly.

I'll try to put it this way. I'm using a signal analyzer (SA) as a part of my testing on a daily basis with some other eqiupments, and I'm trying to make a PERL script to automate the repeititions.

Here's what I found from the manufacturer's application note.

--------------------------------
Command-Line Operation

To speed up frequently used commands (e.g. taking screenshots only from one instrument), you can pass the command via the command line to GPIBShot. The following commands are available:

/{Number between 1 and 31} set IEEE address
/COLOR switch to color mode
/BW switch to b/w mode
/SCREEN take a screen shot
/TRACE{1..4} read out trace data
/HIDE supress trace display on PC
/SHOW shows window again
/END terminates the program
/NAME=<name> specify the name of the file to generate

All combinations ot the commands are possible. The command line is parsed serial.

Example: Calling "GPIBSHOT.EXE /HIDE /20 /COLOR /NAME=IMG1 /SCREEN /NAME=DAT1 /TRACE2 /END" takes a colored hardcopy, stored as "IMG1.WMF", and stores the data of trace 2 with the filename "DAT1.TXT" of IEEE device 20 without displaying the graphical user interface.
--------------------------------

On a second thought, can I just call the said example "gpibshot.exe /hide blah blah blah..." from PERL using the system funcion or one of the two methods you provided?

I was initially thinking calling the command prompt tool (cmd), then call the said command. But it seems like I can just straightly call the command from PERL with the right method?

  • Comment on Re^2: How to call cmd line within PERL?

Replies are listed 'Best First'.
Re^3: How to call cmd line within Perl? (updated!)
by haukex (Archbishop) on Jul 20, 2016 at 07:11 UTC

    Hi bill5262,

    In addition to my other post here's a really quick example:

    #!/usr/bin/env perl use warnings; use strict; use IPC::System::Simple 'system'; my $ieeeaddr = 20; system('GPIBSHOT.EXE','/HIDE',"/$ieeeaddr",'/COLOR','/NAME=IMG1', '/SCREEN','/NAME=DAT1','/TRACE2','/END');

    Update: The line "use IPC::System::Simple;" should have been "use IPC::System::Simple 'system';", since system is not exported by default!

    Hope this helps,
    -- Hauke D

Re^3: How to call cmd line within PERL?
by soonix (Chancellor) on Jul 20, 2016 at 10:29 UTC
    (ps. The Tiny link was broken so I looked into http://perldoc.net/Capture/Tiny.pod hoping that's what you meant to refer)
    http://perldoc.net/Capture/Tiny.pod looks very nice, but outdated, as it currently describes version 0.08,
    while CPAN (Capture::Tiny) and MetaCPAN (Capture::Tiny) have version 0.42

    Update: One year later, we are at version 0.46, perldoc.net still at 0.08 …