|more useful options|
Re: run command from CGI program and display outputby andreychek (Parson)
|on Aug 25, 2002 at 04:16 UTC||Need Help??|
Okay, I played around with your code a bit, and got it to work (using the ls command anyway, I changed it back to your vmquery when I was done). Just to qualify this -- I changed enough of your code to make it function, and I altered the formatting just a bit in some areas. But there very well may be other issues left in your code which need worked out :-)
I changed several things. I added an "if" statement at the beginning that checks to see if the form is being submitted, or if the page is being loaded for the first time. If the page is being loaded for the first time, we just need to display the form. If the form was submitted, we need to run the command, and display the output.
As was mentioned, the -action line needed to be changed to -value. Also, $mediaID was never initialized, I think you meant to grab it from the CGI parameter. And the sub vmquery didn't yet exist. I created that, and have it executing your command.
Before the vmquery command is executed, it's now calling a sub named check_param. It's job is to validate the parameter sent to you by the user. I recommend spending a lot of time in that function, making sure to develop a good regex to verify that the paramter that the user sent you is valid. But without further ado:
Lucy: "What happens if you practice the piano for 20 years and then end up not being rich and famous?"
Schroeder: "The joy is in the playing."