Using cfexecute to execute dos command in windows.
Hi!
Well i have a requirement where i need to check status of
particular service in windows from time to time.
I inferred that we can use cfexecute for this. Well i tried
to use the same but i was not successful in achieving the desired
result.
The following is the code i have written for the above
purpose.
<cfexecute name="sc query Internet Information Services"
arguments="y"
outputfile="d:\Temp\Output.txt"
timeout="90" />
I get the following message:
oldfusion.tagext.lang.ExecuteTag$TimeoutException: Timeout
period expired without completion of sc query Internet Information
Services
at
coldfusion.tagext.lang.ExecuteTag.doStartTag(ExecuteTag.java:170)
at
cfserverchecking2ecfm748178803.runPage(D:\Test\serverchecking.cfm:3)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:147)
at
coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:357)
well i have tried using different timeout periods but it dint
work for me.i have gone crazy with it.
Please advice on this.
Many thanks.
In addition to Mr Black's suggestions, take a look at these
two entries about using cfexecute on Ben Forta's blog
http://www.forta.com/blog/index.cfm/2006/7/31/Using-CFEXECUTE-To-Execute-Command-Line-Util ities
http://www.forta.com/blog/index.cfm/2006/9/11/A-Couple-Of-CFEXECUTE-Gotchas
Similar Messages
-
How to use Runtime execute DOS command?
Hello,
I can not use Runtime class execuste Dos command such as copy and dir.
Is there any suggestion?
Thanks in advance.execute the command with cmd /c (winNT, win2k) or command /c (win9x). Example: "cmd /c dir"
details: http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html -
Using ProcessBuilder to execute multiple commands.
I am having issues getting ProcessBuilder to execute multiple commands in windows.
As an example I would like to execute "dir /w" fallowed by "java.exe some.App arg1 arg2".
I can accomplish this from the command line by using "&".
Example: dir /w & java.exe some.App arg1 arg2 Or: dir /w & dir /c"
For internal commands (i.e. dir and cd) I know that commands in the array being passed to ProcessBuilder must be formatted like {"dir /w", "dir /c"}
see post: [http://www.java-tips.org/java-se-tips/java.util/from-runtime.exec-to-processbuilder.html]
Here is an example of one of the many things I have tried:
{code}
String[] commands = new String[]{"dir /w", "&", "java.exe", "some.App", "arg1", "arg2"};
ProcessBuilder pb = new ProcessBuilder(commands);
pb.start();
{code}
Any other ideas / what am I doing wrong?
Edited by: brianjbrady on May 7, 2009 4:49 PM
Edited by: brianjbrady on May 7, 2009 4:50 PMbrianjbrady wrote:
You can run dir all day long without using cmd.exe. Try it. It works for me.Perhaps you have cygwin in your path.
How are you running dir out of interest (and don't say with a DOS window ;)
import java.io.*;
import java.util.Arrays;
public class Main {
public static void main(String... args) throws IOException {
run("dir");
run("dir.exe");
run("cmd", "/c", "dir");
run("c:\\cygwin\\bin\\dir");
private static void run(String... command) throws IOException {
try {
ProcessBuilder pb = new ProcessBuilder(command);
pb.redirectErrorStream(true);
Process p = pb.start();
InputStream is = p.getInputStream();
System.out.println("\nCommand " + Arrays.asList(command) + " reported");
int b;
while ((b = is.read()) >= 0)
System.out.write(b);
is.close();
p.destroy();
} catch (IOException e) {
System.err.println("\nCommand " + Arrays.asList(command) + " reported " + e);
}Prints
Command [dir] reported java.io.IOException: Cannot run program "dir": CreateProcess error=2, The system cannot find the file specified
Command [dir.exe] reported java.io.IOException: Cannot run program "dir.exe": CreateProcess error=2, The system cannot find the file specified
Command [cmd, /c, dir] reported
Volume in drive D is Work Disk
Volume Serial Number is AC0B-0757
Directory of D:\dev\scratch
26/12/2008 22:15 <DIR> .
26/12/2008 22:15 <DIR> ..
03/09/2007 21:45 <DIR> classes
26/08/2008 20:14 65,280 mynamedpipe
23/11/2008 11:37 201,354 name.ppt.txt
24/10/2008 20:00 201,354 race.txt
05/11/2008 23:17 6,193,334 record.csv
08/01/2009 16:44 704 scratch.iml
27/12/2008 12:29 21,576 scratch.ipr
08/05/2009 20:02 53,258 scratch.iws
28/04/2009 21:34 <DIR> src
07/12/2008 11:44 101 test.txt
8 File(s) 6,736,961 bytes
4 Dir(s) 32,506,023,936 bytes free
Command [c:\cygwin\bin\dir] reported
classes name.ppt.txt record.csv scratch.ipr src
mynamedpipe race.txt scratch.iml scratch.iws test.txt -
How to execute dos command in Java program?
In Perl, it has System(command) to call dos command.
Does java have this thing?
or any other way to execute dos command in java program?
Because i must call javacto compile a file when the user inputed a java file name.Look in the Runtime class, it is implemented using the Singleton design pattern so you have to use the static method getRuntime to get its only instance, on that instance you can invoke methods like
exec(String command) that will execute that command in a dos shell.
Regards,
Gerrit. -
hi experts ,
i need to execute DOS command from SAP .
earlier we have 'GUI_EXEC' WS_EXECUTE , 'WS_DOWNLOAD' etc which are Obsolete now.
as we are using ECC6.0. kindly guide how to do this.
best regards,
RahulTry out...
DSVAS_DOC_WS_EXECUTE_50
or
CL_GUI_FRONTEND_SERVICES=>EXECUTE
<b><REMOVED BY MODERATOR></b>
Thanks & Regards
ilesh 24x7
Message was edited by:
Alvaro Tejada Galindo -
How to execute Dos Command 'Pause' from Java ?
How to execute Dos Command 'Pause' from Java ?
I have read the article in javaworld for Runtime.exec() anomalies.
Can someone please give an insight on this?Thanks Buddy!
That was very useful. Even though its a simple
solution, I never thought about that.Bullshit! Reread reply #7 of http://forum.java.sun.com/thread.jspa?threadID=780193 -
Could not able to execute FTP commands in windows server machines 2012/ windows server 2008.
From windows server 2012 and windows server 2008, Opened port 20,21,22 in firewall bidirectionally. After Establishing connection by passing credentials 230 log in successful.
ftp commands executing getting as " 425 Use Port or PASV first" , "500 Illegal PORT command".
But I could able to do windows client machines like windows 7 and windows 8 with same environment
Note : Firewall ports are opened. have tested by making firewall down to avoid filters.
Pandiyan MuthuramanHi Pandiyan Muthuraman,
Did you mean even you disable or open the related port the FTP issue still exist? I found this errors most time occur when we use the ISA firewall and the FTP configured passive
mode, if you have ISA firewall please refer the following KB to fix this issue.
How to enable passive CERN FTP connections through ISA Server 2000, 2004, or 2006
http://support.microsoft.com/kb/300641
The have a specific form for the IIS question, if you have the further IIS related question you can ask in IIS forum.
IIS support forum
http://forums.iis.net/
Thanks for your understanding and support
We
are trying to better understand customer views on social support experience, so your participation in this
interview project would be greatly appreciated if you have time.
Thanks for helping make community forums a great place. -
Execute dos commands through java
Hi,
Im trying to execute dos commands through java like
try {
java.lang.Runtime.getRuntime().exec("cmd /c cls");
}catch(IOException e){
System.out.println(e.getMessage());
}Not sure if its possible? however
open notepad would work
try {
java.lang.Runtime.getRuntime().exec("notepad");
}catch(IOException e){
System.out.println(e.getMessage());
}Im trying to execute a cls commands to clear screen but without luck.The question is, which shell do you want to clear?
I don't really know, but it could be that Runtime.exec executes its command in a new shell window... -
EXECUTE DOS COMMANDS WITH JAVA
I'm new to java and I want to execute dos commands by java
can someone help me by by anyway?
like tell me the packages or methods I need
or give me links to sites?
thanksNo Arguments:
try {
// Execute a command without arguments
String command = "ls";
Process child = Runtime.getRuntime().exec(command);
// Execute a command with an argument
command = "ls /tmp";
child = Runtime.getRuntime().exec(command);
} catch (IOException e) {
}With Arguments:
try {
// Execute a command with an argument that contains a space
String[] commands = new String[]{"grep", "hello world", "/tmp/f.txt"};
commands = new String[]{"grep", "hello world", "c:\\Documents and Settings\\f.txt"};
Process child = Runtime.getRuntime().exec(commands);
} catch (IOException e) {
} -
Can we execute DOS Commands from a Java Application
I just want to know whether we can execute DOS Commands from a Java Application.
Thanks.hi,
try this:
Runtime.getRuntime().exec("cmd /c start abc.bat");
andi -
Execute DOS command in current window!
All:
Here is my code :
import java.io.*;
public class BuildScript {
public static void main ( String[] args ) {
String[] command = {"C:\\winnt\\system32\\cmd.exe", "cls"};
try {
Process process = Runtime.getRuntime().exec ( command );
process.waitFor();
} catch ( InterruptedException e ) {
e.printStackTrace();
System.exit(-1);
} catch ( IOException e ) {
e.printStackTrace();
System.exit(-1);
System.out.println ( "DONE!" );
I just want to exeute some simple DOS command from Java application. And then I run this code, it hangs there for ever. I comments out "process.waitFor()", then it print out the "DONE" however it seems that it just open another console and clear that one and exit. For the main console I start my code, nothing happened.
Can anyone help me out how to execute the dos command in current console window.
ThanksCan anyone help me out how to execute the dos command in current console window.Sorry to say but there is no way to do that.
The best way to clear the screen is to print a few hundred newlines.
Trust me, this is a frequently asked question. -
Cfexecute not executing CVS commands ina bat file
We are running CF 7.0 on Windows server.
I am creating a bat file containing both DOS commands and CVS
commands.
When executing the bat file via <CFexecute> the DOS
commands execute, but the CVS commands do not.
When running the bat file from the DOS command prompt, all
commands (DOS and CVS) run as expected.
Anyone have any ideas?
ThanksOn Wed, 24 Jan 2007 23:03:48 +0000 (UTC), JRoccaforte wrote:
> That could be an issue. I am however using my login and
password in the commands
Ian didn't mean the CVS permissions, he meant the filesystem
/ OS
permissions. The a/c that ColdFusion uses to access the file
system and
other system resources is very limited, by default.
You need to login (to the OS) as the a/c CF is using, and see
if you can
execute your batch file.
Adam -
How to execute DOS command in Java?
I want to execute a dos command in Java,such as execute test.bat command? How to realize it?
Thanks in advance!http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
I found this article really useful in solving this. Hope it helps.
Cheers,
John -
Error Message Displayed while executing FNDLOAD Command in windows machine
Hi,
I am getting the following error message while executing the FNDLOAD Command in Windows Machine. Can any one give some clarifications to solve this issue.
FNDLOAD Command Used:*
+./FNDLOAD apps/[email protected]:1521:OA10 0 Y DOWNLOAD D:\oracle\oa10appl\xdo\11.5.0/patch/115/import/xdotmpl.lct xdotmpl.ldt XDO_DS_DEFINITIONS APPLICATION_SHORT_NAME=PO
Error message Displayed for above command:_
APP-FND-01564: ORACLE error 6401 in AFPCOA
Cause: AFPCOA failed due to ORA-06401: NETCMN: invalid driver designator
Let me know the solution this issue
Regards
Arif MohammedHi Hussein,
Thanks for your response, Let me explain in detail that the error I am facing while running FNDLOAD Command.
I have executed the below command in CYGWIN which results in error while calling FNDLOAD.
*$ java oracle.apps.xdo.oa.util.XDOLoader DOWNLOAD -DB_USERNAME apps -DB_PASSWORD apps -JDBC_CONNECTION 16.89.26.52:1521:OA10 -LOB_TYPE TEMPLATE -APPS_SHORT_NAME PO -LCT_FILE $XDO_TOP/patch/115/import/xdotmpl.lct -LANGUAGE en -TERRITORY US -LOG_FILE SHW.log;*
I got the below error message while executed the above command (Highlighted in BOLD):
$ cat SHW.log
XDOLoader started: Tue Nov 15 20:27:18 PST 2011
Parameters passed to XDOLoader...
[TERRITORY] [US]
[DB_USERNAME] [apps]
[LCT_FILE] [C:\oracle\vis10appl\xdo\11.5.0/patch/115/import/xdotmpl.lct]
[DOWNLOAD] [DOWNLOAD]
[JDBC_CONNECTION] [16.89.26.52:1521:OA10]
[LANGUAGE] [en]
[DB_PASSWORD] [apps]
[LOB_TYPE] [TEMPLATE]
[LOG_FILE] [SHW.log]
[APPS_SHORT_NAME] [PO]
Start downloading...
Downloading files from XDO_LOBS: SELECT FILE_DATA, LOB_CODE, LOB_TYPE, APPLICATI
ON_SHORT_NAME, FILE_NAME, LANGUAGE, TERRITORY, XDO_FILE_TYPE FROM XDO_LOBS WHERE
APPLICATION_SHORT_NAME = :APPS_SHORT_NAME AND LOB_TYPE in (:TEMPLATE, :TEMPLAT
E_SOURCE) AND LANGUAGE = :LANGUAGE AND TERRITORY = :TERRITORY
Downloading files from XDO_LOBS: SELECT L.FILE_DATA FILE_DATA, B.TEMPLATE_CODE L
OB_CODE, L.LOB_TYPE LOB_TYPE, L.FILE_NAME FILE_NAME, L.LANGUAGE LANGUAGE, L.TERR
ITORY TERRITORY, L.XDO_FILE_TYPE XDO_FILE_TYPE, L.APPLICATION_SHORT_NAME APPLICA
TION_SHORT_NAME FROM XDO_TEMPLATES_B B, XDO_LOBS L WHERE B.APPLICATION_SHORT_NAM
E = :APPS_SHORT_NAME AND B.TEMPLATE_CODE = L.LOB_CODE
Generating LDT file: xdotmpl.ldt
Calling FNDLOAD: FNDLOAD apps/[email protected]:1521:OA10 0 Y DOWNLOAD C:\oracle\
vis10appl\xdo\11.5.0/patch/115/import/xdotmpl.lct xdotmpl.ldt XDO_DS_DEFINITIONS
APPLICATION_SHORT_NAME=PO
APP-FND-01564: ORACLE error 6401 in AFPCOA
Cause: AFPCOA failed due to ORA-06401: NETCMN: invalid driver designator.
The SQL statement being executed at the time of the error was: and was executed
from the file .
Generating DRVX file: xdotmpl.drvx
XDOLoader done successfully: Tue Nov 15 20:27:30 PST 2011
$
So i decided to run the FNDLOAD Command alone in CYGWIN which is highlighted and still im facing the same issue but if i run the below command it works fine and getting download.
*./FNDLOAD apps/[email protected]:1521:OA10 0 Y DOWNLOAD D:\oracle\oa10appl\xdo\11.5.0/patch/115/import/xdotmpl.lct xdotmpl.ldt XDO_DS_DEFINITIONS APPLICATION_SHORT_NAME=PO*
Hope you understand the problem which im facing. Let me know some solutions from your side to solve this issue.
Regards,
Arif Mohammed -
Execute DOS command from java application
Hello,
I want to execute a DOS command (MOVE, in order to move an image from a folder to an other) from a java application. How can I do this?
FrancescoYes I have tested it and it is working but only when executing a bacth file. For instance:
Runtime rt = Runtime.getRuntime();
try{
Process proc = rt.exec("move.bat");
}catch(Exception ex){
ex.printStackTrace();
}and the command in move.bat is:
move c:\\temp\\*.gif C:\\temp2
You don't have to use double slashes in batch files, only in Java. But anyway it is working both ways.
It is not working when you try to execute the command without the batch file:
Process proc = rt.exec("move c:\\temp\\*.gif C:\\temp2"); -> this will not work.
It should work. Try to execute another command to see what happens.
Maybe you are looking for
-
How to install Windows 8.1 on Macbook Pro
I have a 13-inch Mid 2010 MacBook Pro operating on OS X Mavericks 10.9.2. I recently purchased Windows 8.1 as I was told by the Geek squad I could install it on my MacBook Pro. I keep getting this message every time I try to run BootCamp I get this:
-
How to Restore a data table from a 'dmp' file in a database of oracle ?
Hello, I want just to restore one table belonging in a database. I Have the dmp file which I must restore. Then I am asking if it's possible to restore only a table not all the databse ? If Yes, What I mut do to realize it ? I need really helps . Reg
-
Saving editable column contents in Std. Table using ALV
Hi All, I developed a ALV report which displays list of sales orders of particular customer, in this report created by name is editable column. Now i want to save the created by name after user changes the contents of this column and click on save
-
Virus Scan for SAP XI , J2EE configuration
Hi Experts, We have a virus scan interface NW-VSI provided by SAP. Different AV products are now producing and certifying for this and providing the Virus Scan Adapter and Virus scan engine integrated with SAP NW system. We can use this to scan virus
-
Upload to file in the presentation server
Hi Guyz, I got a report, which would download output into a .txt file using function module "download", but one field is not getting downloaded into that. how to check that? plz let me know.. thanks a lot.. venu.