cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Script Help

davehaigh
11-Garnet

Script Help

I've modified M. Fischer's ptcstat script to work with my setup, however I'm looking to do something a lot simpler than that perl script. (The otcstat stuff used to be available on PTC's website, it's disappeared.)

As someone else suggested some time back, I copied the ptcstatus command and removed the more statement from it. I'm then calling that batch file to output the license usage

However after spending some time looking on line, I've hit a wall. Perhaps it's just brain fade on a Friday.

I have this command, that outputs the single line.

"C:\ptc\Creo 2.0\Parametric\bin\myptcstatus" | findstr /C:" PROE_Flex3C"
PROE_Flex3C 5 32

I can add >>flex3c.dat to the end to get it to write the output to a file. Great.

But, what I'd really like it to do is find the number in use, the second token, and then set a variable with that number so I can output both the date/time and the value to a line in the data file.

All the "for" syntax I've tried fails.

1st try:
for /F "tokens=2 usebackq" %A ("C:\ptc\Creo 2.0\Parametric\bin\myptcstatus" | findstr /C:" PROE_Flex3C")DO set FLEX3C=%A
("C:\ptc\Creo 2.0\Parametric\bin\myptcstatus" was unexpected at this time. <-- Error I get.


David Haigh
Phone: 925-424-3931
Fax: 925-423-7496
Lawrence Livermore National Lab
7000 East Ave, L-362
Livermore, CA 94550


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.
2 REPLIES 2
FV
17-Peridot
17-Peridot
(To:davehaigh)

Hi all,


David, in 'for' - you cannot use pipe (|)...


You hadthe right idea, first output to a text file (flex3c.dat), then use the text file as an argument in 'for' command, so instead of saying


...myptcstatus | findstr ...


use ... %A ( 'type flex3c.dat' ) DO ...


Also, if your loop variable is %A then the second token should be referenced as %B, unless tokens=2 affects it, don't remember.


HIH.


Feliks.

In Reply to David Haigh:


I've modified M. Fischer's ptcstat script to work with my setup, however I'm looking to do something a lot simpler than that perl script. (The otcstat stuff used to be available on PTC's website, it's disappeared.)

As someone else suggested some time back, I copied the ptcstatus command and removed the more statement from it. I'm then calling that batch file to output the license usage

However after spending some time looking on line, I've hit a wall. Perhaps it's just brain fade on a Friday.

I have this command, that outputs the single line.

"C:\ptc\Creo 2.0\Parametric\bin\myptcstatus" | findstr /C:" PROE_Flex3C"
PROE_Flex3C 5 32

I can add >>flex3c.dat to the end to get it to write the output to a file. Great.

But, what I'd really like it to do is find the number in use, the second token, and then set a variable with that number so I can output both the date/time and the value to a line in the data file.

All the "for" syntax I've tried fails.

1st try:
for /F "tokens=2 usebackq" %A ("C:\ptc\Creo 2.0\Parametric\bin\myptcstatus" | findstr /C:" PROE_Flex3C")DO set FLEX3C=%A
("C:\ptc\Creo 2.0\Parametric\bin\myptcstatus" was unexpected at this time. <-- Error I get.


David Haigh
Phone: 925-424-3931
Fax: 925-423-7496
Lawrence Livermore National Lab
7000 East Ave, L-362
Livermore, CA 94550

tmcnaney
12-Amethyst
(To:davehaigh)

In Reply to David Haigh:


All the "for" syntax I've tried fails.

1st try:
for /F "tokens=2 usebackq" %A ("C:\ptc\Creo 2.0\Parametric\bin\myptcstatus" | findstr /C:" PROE_Flex3C")DO set FLEX3C=%A
("C:\ptc\Creo 2.0\Parametric\bin\myptcstatus" was unexpected at this time. <-- Error I get.


The command below is onesyntax that should work. Replace PROE_FLEX3C with your actual license INCREMENT name.


By using ‘-f’ option the report will be more efficient and targeted to request status for that specific licensed feature.


To incorporate in a batch file, replace %A with %%A


Also, if the ptcstatus command is in a directory with spaces use the old 8.3 path (dir /X).


for /F "usebackq tokens=1,2" %A in (`D:\PTC\Creo2~1.0\Parametric\bin\ptcstatus.bat -nopause -f PROE_FLEX3C ^| find "PROE_FLEX3C"`) do @echo %A,%B

As an alternative to the 8.3 syntax, this will also work:


subst 1: "D:\PTC\Creo 2.0"

replace back-quoted command if FOR with `1:\Parametric\bin\ptcstatus.bat ...`

subst 1: /D
Top Tags