Is it possible in CF to start the command line?

Is it possible to send commands from on PC to another PC to start the command line, give it commands, and get return of pass/fail?

If so, could you share a code example?
LVL 1
g118481Asked:
Who is Participating?
I wear a lot of hats...

"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.

Dain_AndersonCommented:
Have you tried CFEXECUTE?

 I'm pretty sure you can with that:

<CFEXECUTE NAME="\\server_name\share_name\myProcess.exe" ARGUMENTS="put arguments here" VARIABLE="PASS_FAIL"/>

Then, to see if it passed or failed, use #PASS_FAIL#

-Dain
0
Tacobell777Commented:
What is it exactly what you are trying to do?
You might also be able to do it with Windows Scripting, i.e. create a WSCRIPT object and do what you need to do..
0
g118481Author Commented:
This is what I need to do:
1.  Start an applicaton on a remote machine.  (the application is not a web app)
2.  The application has a command line interface.
3.  Send commands to the application for it to do something.
4.  Get status info back.
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Dain_AndersonCommented:
Ok, that sounds like what I was thinking. CFEXECUTE is one way to achieve this. The ARGUMENTS argument is the method in which you send commands to the application. The VARIABLE argument is the name you assign to the returned information, and can be used in any CFOUTPUT block. The NAME argument is the path to the application (which can be on another server). Optionally, you can send an array to the ARGUMENTS argument which is in turn is treated as a space-delimited set of tokens. There are a few other arugments that do other things as well, such as the OUTPUTFILE one that allows you to save the returned information to file, as well as a TIMEOUT argument.

Hope that helps,

-Dain
0
g118481Author Commented:
Dain,

I think you have put me on the right path, thanks.
Also, you have probably heard this a million time, but could you provide a code example.  One that connects to a remote machine, and has syntax for arguments?

I increased the points to 300, in order to compensate for this added requirement.
0
Dain_AndersonCommented:
Sure, no problem. Here are a few that I currently use:

This one I use for my Text-to-Speach engine, based on options the user selects from a form. Each item in the ARGUMENTS value is separated by a space, but the .bat will treat each space as the delimiter for another argument.

<CFEXECUTE NAME="#exPath#ttsapp_wav.bat" ARGUMENTS="#FORM.wavFile# dummy #FORM.voiceName# 122869erudotTTS #inTextFile# #mp3file#"
      OUTPUTFILE="#mediaPath#_logs\out_#FORM.fileUUID#.txt" />
      
Here's one I use to convert PowerPoint presentations to Flash moves:

<CFEXECUTE NAME="\\tdot-office\_customtags\_ppt2html\PPT2HTMLBatch.exe" ARGUMENTS="#This.IncDir#" />

Where, #This.IncDir# is the destination for the Flash file. Each EXE or BAT file you use will have its own set of arguments and order in which they need to be sent. You'll have to check the applications commandline documentation for that information.

-Dain
0
g118481Author Commented:
Dain,

Taking from your example, I ran this code, and it fails.  Any suggestions?  Shouldn't I be required to pass the ID and password for the target machine?

Here is the error message:
//////////////////////////////////error///////////////////////////////////////////
Error Occurred While Processing Request
Error Diagnostic Information
Cannot execute \\cmdevelop2\WINNT\System32\cmd.exe

Windows NT error 53 occurred.

The error occurred while processing an element with a general identifier of (CFEXECUTE), occupying document position (14:1) to (14:100).


/////////////////////////////////////code///////////////////////////////////////////
<cfset exPath = "\\cmdevelop2\WINNT\System32\">
<cfset mediaPath = "c:\documents\logs\">

<CFEXECUTE NAME="#exPath#cmd.exe" ARGUMENTS="ipconfig"      OUTPUTFILE="#mediaPath#cfexecute.txt" />
0
Dain_AndersonCommented:
Ok, no problem. Here's one possible solution, but I'm sure there are many other more elegant solutions out there. I tried this in our server farm and it worked great:

<CFEXECUTE NAME="c:\windows\system32\cmd.exe" ARGUMENTS="/C NET USE Y: ""\\xander\c$\windows\system32"" PASSWORD_HERE /USER:PUT_DOMAINNAME_HERE\USER_NAME_HERE" />
<CFEXECUTE NAME="c:\windows\system32\cmd.exe" ARGUMENTS="/C Y:\ipconfig /ALL" OUTPUTFILE="C:\Inetpub\wwwroot\sa_local\cfexecute.txt" />
<CFEXECUTE NAME="c:\windows\system32\cmd.exe" ARGUMENTS="/C NET USE Y: /DELETE" />

This creates a share using authentication, runs the process, then removes the share.

Hope that helps,

-Dain
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.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.