Question
Script Help - Solution
Ok, I gave up on doing this with standard windows commands.
I installed Perl, and had a guy here that knows it well, help me get the output I wanted. (I've got to learn Perl!)
Here's the command using Perl to format the output:
"C:\ptc\Creo 2.0\Parametric\bin\myptcstatus" | perl -ne "print scalar(localtime(time)), \"\t\", $1, \"\t\", $2, \"\n\" if $_ =~ /\s+(PROE_Flex3C)\s+(\d+)\s+\d+/ ">>c:\PTC\FLEX3C_data.txt
It outputs this, with tabs between the elements so it can be imported easily into Excell. (import using delimiters, tabs)
Mon Mar 3 10:19:43 2014 PROE_Flex3C 5
You can change what it's looking for to output usage info for other licenses. Like this:
C:\Users\haigh1>"C:\ptc\Creo 2.0\Parametric\bin\myptcstatus" | perl -ne "print scalar(localtime(time)), \"\t\", $1, \"\t\", $2, \"\n\" if $_ =~ /\s+(Mathcad)\s+(\d+)\s+\d+/ ">>c:\PTC\Mathcad_data.txt
The myptcstatus command is a copy of the ptcstatus.bat file with this information removed: (Edit with notepad++ to see line numbers.)
Line #
69 %status_cmd% %forcea% %1 %2 %3 %4 %5 | more %more_flag%
70 pause
The Perl we used was ActivePerl.
Just add a pipe and the name you want to look for. You can add as many as you want. Your output will look like this:
Mon Mar 3 10:13:34 2014 PROE_Flex3C 5
Mon Mar 3 10:13:34 2014 Mathcad 6
The advantage of this over M. Fischer's ptcstat script, is it doesn't have to be installed on the server, you don't have to install IIS, and it's not confused by reserved licenses. Also it's only one line! You can put as many lines in a batch file as you want to track any license feature you want, outputting separate data files for each. All you need is an "at" command to run your batch file periodically.
David Haigh
This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
I installed Perl, and had a guy here that knows it well, help me get the output I wanted. (I've got to learn Perl!)
Here's the command using Perl to format the output:
"C:\ptc\Creo 2.0\Parametric\bin\myptcstatus" | perl -ne "print scalar(localtime(time)), \"\t\", $1, \"\t\", $2, \"\n\" if $_ =~ /\s+(PROE_Flex3C)\s+(\d+)\s+\d+/ ">>c:\PTC\FLEX3C_data.txt
It outputs this, with tabs between the elements so it can be imported easily into Excell. (import using delimiters, tabs)
Mon Mar 3 10:19:43 2014 PROE_Flex3C 5
You can change what it's looking for to output usage info for other licenses. Like this:
C:\Users\haigh1>"C:\ptc\Creo 2.0\Parametric\bin\myptcstatus" | perl -ne "print scalar(localtime(time)), \"\t\", $1, \"\t\", $2, \"\n\" if $_ =~ /\s+(Mathcad)\s+(\d+)\s+\d+/ ">>c:\PTC\Mathcad_data.txt
The myptcstatus command is a copy of the ptcstatus.bat file with this information removed: (Edit with notepad++ to see line numbers.)
Line #
69 %status_cmd% %forcea% %1 %2 %3 %4 %5 | more %more_flag%
70 pause
The Perl we used was ActivePerl.
Just add a pipe and the name you want to look for. You can add as many as you want. Your output will look like this:
Mon Mar 3 10:13:34 2014 PROE_Flex3C 5
Mon Mar 3 10:13:34 2014 Mathcad 6
The advantage of this over M. Fischer's ptcstat script, is it doesn't have to be installed on the server, you don't have to install IIS, and it's not confused by reserved licenses. Also it's only one line! You can put as many lines in a batch file as you want to track any license feature you want, outputting separate data files for each. All you need is an "at" command to run your batch file periodically.
David Haigh
This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.

