?
Solved

Is it possible in CF to start the command line?

Posted on 2004-12-01
10
Medium Priority
?
218 Views
Last Modified: 2013-12-24
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?
0
Comment
Question by:g118481
  • 4
  • 3
8 Comments
 
LVL 9

Expert Comment

by:Dain_Anderson
ID: 12720325
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
 
LVL 17

Expert Comment

by:Tacobell777
ID: 12721522
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
 
LVL 1

Author Comment

by:g118481
ID: 12728936
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
Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

 
LVL 9

Expert Comment

by:Dain_Anderson
ID: 12729418
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
 
LVL 1

Author Comment

by:g118481
ID: 12729611
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
 
LVL 9

Expert Comment

by:Dain_Anderson
ID: 12729777
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
 
LVL 1

Author Comment

by:g118481
ID: 12730237
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
 
LVL 9

Accepted Solution

by:
Dain_Anderson earned 1200 total points
ID: 12731239
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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question