wangruonan has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I am using perl to run furmark and speedfan, but i am not sure how to add furmark & speedfan command line into my script, like furmark resolution and fan speed. Here is my code:
#!/usr/bin/perl # process.plx use warnings; use strict; use Win32::Process; use Win32; my $speedfan; my $furmark; my $counter; my $hot; my $cold; print "Please enter cycle count:"; $counter=<STDIN>; print "Please enter hot cycle time:"; $hot=<STDIN>; print "Please enter cold cycle time:"; $cold=<STDIN>; sub ErrorReport{ print Win32::FormatMessage(Win32::GetLastError()); } Win32::Process::Create($speedfan, "C:\\Program Files (x86)\\SpeedFan\\speedfan.exe", "notepad.txt", 0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport (); print "SpeedFan has been opened.\n"; while ($counter > 0) { Win32::Process::Create($furmark, "C:\\Program Files (x86)\\Geeks3D\\Benchmarks\\FurMark_1.12.0\\Fur +Mark.exe", "notepad.txt", 0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport (); print "Furmark has been opened at $counter"; sleep $hot; print "timesup.\n"; my $exit_code = 1; $furmark->Kill($exit_code); $counter = $counter-1; sleep $cold; }
Please kindly advise me. Thank you!

Replies are listed 'Best First'.
Re: Furmark & Speedfan command line in perl
by AppleFritter (Vicar) on Sep 05, 2014 at 09:43 UTC

    Howdy wangruonan, welcome to the Monastery!

    I take it your question is how to pass command line arguments to the programs you're calling? Quoting the documentation for Win32::Process:

    Win32::Process::Create($obj,$appname,$cmdline,$iflags,$cflags,$curdir)

    Creates a new process.

    Args: $obj container for process object $appname full path name of executable module $cmdline command line args $iflags flag: inherit calling processes handles or not $cflags flags for creation (see exported vars below) $curdir working dir of new process

    In other words, just replace "notepad.txt" in your script with strings containing the desired arguments.

      Hey thank you AppleFritter. I replaed notepad.txt with my FurMark command line: "/nogui /width=1024 /height=728 /disable_osi /log_gpu_data /log_gpu_data_polling_factor=6". But it's not working..
      #!/usr/bin/perl # process.plx use warnings; use strict; use Win32::Process; use Win32; my $speedfan; my $furmark; my $counter; my $hot; my $cold; print "Please enter cycle count:"; $counter=<STDIN>; print "Please enter hot cycle time:"; $hot=<STDIN>; print "Please enter cold cycle time:"; $cold=<STDIN>; sub ErrorReport{ print Win32::FormatMessage(Win32::GetLastError()); } Win32::Process::Create($speedfan, "C:\\Program Files (x86)\\SpeedFan\\speedfan.exe", "notepad.txt", 0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport (); print "SpeedFan has been opened.\n"; while ($counter > 0) { Win32::Process::Create($furmark, "C:\\Program Files (x86)\\Geeks3D\\Benchmarks\\FurMark_1.12.0\\Fur +Mark.exe", "/nogui /width=1024 /height=728 /disable_osi /log_gpu_data /log_gp +u_data_polling_factor=60", 0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport (); print "Furmark has been opened at $counter"; sleep $hot; print "timesup.\n"; my $exit_code = 1; $furmark->Kill($exit_code); $counter = $counter-1; sleep $cold; }

        You're welcome, partner! *tips hat*

        I just looked into why this isn't working - turns out you must also include the program's name in your command line arguments, so if you prepend "furmark" or "furmark.exe" to the parameters, it should work.

        Same for the SpeedFan invocation (you still have a "notepad.txt" there, BTW).