The following routine works fine in regular, Windowed Maple:
############################################################################ # purpose: calculate/graph totalCPU usage # # language: Maple 7 # # note(s): (1) forward slashes are equivalent to backslashes for # specifying directories and files # # who when what # -------- ---------- -------- # chuckm 08/23/2001 creation # ############################################################################
cleanup the Maple environment and set global variables
restart: with(plots): with(stats): with(describe): Directory := "C:/Temp/ESS_PerformanceReports94": InFile := "" || Directory || "/" || "Memory_and_CPU_Stats.maple_input060": OutFile := "" || Directory || "/" || "Memory_and_CPU_Stats.jpg":
define the procedure that will do the work
totalcpu := proc(InFile_Name::string, OutFile_Name::string) local FortressData: print ("...generating CPU Utilization :"): print ("Input = " || InFile_Name): print ("Output = " || OutFile_Name): FortressData := readdata(InFile_Name,5): map(u -> [u[2],u[5]],FortressData): plotsetup(jpeg, plotoutput=OutFile_Name): plot(%,x=0..24,y=0..100,symbol=POINT, \ title="Plot of % CPU Usage vs Time of Day",\ labels=["24-hour time-of-day","% CPU Utilization"]): end proc:
call the routine we just defined
I send it to CMAPLE, for batch processing, as follows:
cmaple -q -c "read C:/Programs/ESS_Server_TotalCPU_Report.mapletext"
However, I receive an undecipherable message:
Error, incorrect syntax in parse: ‘;‘ unexpected (6) I get the same message if I pass in only a "print (’hello’)" statement.
Remove the backslashes at the ends of those lines. They do weird things when they are at the ends of lines in text files.
I think one problem is that if you try to run the command
read C:/Programs/ESS_Server_TotalCPU_Report.mapletext
in any version of Maple, you will get an error. The argument to read needs to be either a string or a symbol, so you need either double or backward quotes around it. Backward quotes should work with no difficulty using a Windows command processor (but not a UNIX-like shell!), i.e. try this:
cmaple -q -c "read `C:/Programs/ESS_Server_TotalCPU_Report.mapletext`"
But you can probably avoid the whole issue by running Maple like this:
cmaple -q < C:/Programs/ESS_Server_TotalCPU_Report.mapletext
You may need to replace the forward slashes by backward slashes (because the filepath is being parsed by the Windows command processor, not by Maple). This is essentially the way I run Maple from a perl CGI script, under Windows, which works.
Another problem with the -c option is that, according to the online help, spaces are not allowed in the command, although you could probably get around that by putting the read argument in parentheses with no spaces.
If you remove the spaces from your "print (’hello’)" example, then it should work. For example, using Maple 7 on Windows NT, the following prints hello and then quits:
cmaple -q -c print('hello') -c quit