Pass value from html to batch file

Hello -
I'm working with an existing html/php web page that has about 7 links that call almost identical batch files to perform a series of steps, such as renaming a file and moving it to another location.

I'd like to use just a single batch file by passing a parameter from the web page to the batch file, and based on this value, will determine the new name and location for the file. The value of the parameters can be as simple as a, b, c, d, e, f, g; it's just a way for the batch file to know which link the user clicked on.

Currently I have a link such as:
href="file:\\dev_server\scripts\script1.cmd"
href="file:\\dev_server\scripts\script2.cmd"
etc...

I'd like to have:
href="file:\\dev_server\scripts\script.cmd /p='a'" (or however one would indicate a parameter)
href="file:\\dev_server\scripts\script.cmd /p='b'"
etc.

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Does any of that even work at all? I ask because if you are using Firefox or Chrome, they won't open those 'file://' links.

0

tancatOracle DeveloperAuthor Commented: 2015-03-03

What I currently have works. The desire is to have a single batch file instead of seven.

The batch files execute on the server, I believe. I mean, they are stored on the server; when someone clicks on the link and a command box pops up, isn't that executing on the server but displaying on the client?

The users used to click on a separate link for each step, but the batch files I'm using now just echo a comment to the user when each step is completed (along with a pause). If the step doesn't complete successfully, an error message is displayed and the users will take a screen shot and send it to me.

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

There are a couple of gotchas to be aware of, such as checking that a value has actually been passed, and making sure that a user can't do something unintended by simply typing a different querystring into the browser, but these issues are generally straight-forward to prevent.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

I think the only thing I still need help with is to allow some acknowledgement from the user. Currently the pause command in the batch file allows the user to see that the previous step was completed and they can hit any key to proceed to the next step; if the previous step was not successful it simply prints an error message so that I know where to troubleshoot. Is there a way to do this, to get the user to "hit any key" (or something equivalent) in the myScript.php file?

I have some "button" code that I can modify, but I was hoping for something simpler.

I have not yet reviewed the links that you gave me; I'm sure a 'pause' equivalent is there, I just haven't figured out the terminology yet.

Thank you so much for sharing with me. I will definitely pay it forward when I become knowledgeable on this subject. :-)

There's no pause as such, as the PHP script will output to the browser once it's finished. If you want to break it into steps, then you could simply display another link. So the first link points to step1.php. You do what you need to in there, and if it's successful, you simply echo out another link to step2.php with a message saying Successful. If your step1.php failed, then simply echo out a message:

As you build up your app, you can get more creative - like emailing you or logging the info if it fails, using a button instead of a link for the next step (a simply press of the Enter key would then proceed). PHP is pretty powerful, so you're only limited by your creativity (and current knowledge base!)

0

tancatOracle DeveloperAuthor Commented: 2015-03-08

My apologies for being incommunicado. It was strongly suggested that I needed to work on the documentation for this project, at which point I thought of a few other things or ways to solve some problems. (I'm not sure that having the programmer write the requirements in the middle of development is the best course of action...)

As this question is solved, I will accept a solution. (No promises that I won't be back, however!)

Dave - to answer your question, for this particular functionality my company only supports IE. However, I do have it working in Firefox on my computer because I am using the Local Filesystem Links add-on.

0

tancatOracle DeveloperAuthor Commented: 2015-03-08

I am very appreciative of the help and support that I have received from Chris Stanyon. I have been able to solve a problem at work quickly, and look like I really know what I'm doing!