Running a dos command
Hi guys,
I've created a prog that runs as a server and you can telnet into and give it commands to execute programs on the remote computer. All using runtime.exec().
Just wondering if anyone knows how i can send a dos command to it such as COPY \\192.168.1.2\temp \\192.168.1.3\temp.
If i use "cmd.exe /c start cmd.exe" then it opens the window its just i cant remember how to send the dos command to it, as i actually wrote the program several months ago.
Cheers for any help
Andy
One way is to put the dos commands inside a batch file and 'exe' the batch file. Not sure if you also mean you don't want to see the new dos window ( use min to minimize that new window for that ), or not.
Similar Messages
-
How can I run a dos command from java on windows 98, 95?
The usage of cmd.exe in the java program to run a dos command on windows 98. 95 doesn't work as the equivalent command is command.exe
But using the command.exe in the java program makes my program to hang.hi,
As u mentioned, u cannot use the cmd.exe in win9x environment as cmd.exe is specific to windows NT, you can use the command.exe without any hitches.
for eg
java.lang.Runtime.getRuntime().exec("start command /K a.bat"); should run the batch file a.bat..
if the problem persists, try posting the snippet of code that you are using.
cheerz
ynkrish -
How to run a DOS command from an Oracle form.
How can I run a DOS command from an Oracle form (i.e. open the calculator located at c:\windows\system32\calc.exe)?
first of all get the environment variable for the c:\windows\system32 direcotry for any of the windows
you can use get variable from the ora env package
now cancat the system32 variable with the calc.exe string
now pass the string with host command as parameters
this process will work for all type of windows. -
Running MS-DOS commands using Runtime.exec()
Is there any way to run the dos commands like copy and del from our java program? Actually I want to implement a visual console kind of thing and have to transfer the commands to the prompt and get the result string that is to be displayed in a JTextArea?
Please help me. It'll be very nice of you...thanksI can help you in two ways:
o by telling you to run cmd.exe and pass the rest as parameters.
o by pointing out this is the wrong forum for you equestion. -
How to run multiple DOS commands from a single Webutil Client_Host session?
Hello all,
I have a requirement where I need to create an interface with SVN from Forms for basic checkin-checkout of files.
So, I've been trying to use webutil client_host to open a command line session and issue svn commands.
For svn, sometimes I need to give multiple commands like change to a particular directory and then run an svn command.
But client_host takes in only one command at a time and I'm unable to issue a series of DOS commands to perform
a particular task.
Is there a way to do this?
Pls suggest.
Regards,
SamFirst your original question... You can put more than one DOS command on a single line, simply separate each command with an ampersand (&). For example:
mkdir c:\abc & cd abc & dir*
Regarding your concerns about performance, well that would depend on exactly what you mean. Using CLIENT_HOST (or HOST on the server) simply opens a shell (DOS in this case) then passes your command to it. The performance of performing this action really isn't measurable. Basically you are just pressing a button and you should get a near immediate action. As for the performance of executing each command, that has nothing to do with Forms. Once the command is passed to the shell, the rest is a function of the shell and whatever command you passed.
Having said that, if you were to write something sloppy like a loop (in pl/sql) which called CLIENT_HOST lots of times repeatedly, then yes there would be a performance problem because the pushing of the button will cause an exchange to and from the server and each cycle in the loop will do the same.
So the answer to how performance is impacted will depend on what exactly you need to accomplish. If it is a single call to CLIENT_HOST, this should be fine. -
Running a DOS Command through a JAVA GUI
I'm trying to run a command line through a GUI.. how would i go about doing this... suppose i wanted to run the following dos command inside a java program:
String command = "jar cvf classes.jar open.java close.java"
Does anyone have a good model I can look at that can implement a dos command?Maybe you can refer to this resource , I can not remember the Class, It seems like this Runtime.getRuntime().exec() ?? It can execute your command.
-
Problem in running MS DOS command in ODI
Hi,
I am trying to execute the following command through ODI-
cmd /c dir E:\Files\LLP_AFS\*.txt /b /a:-d > E:\Files\LLP_AFS\Filenames_llp_afs.txt
But it is giving me error.I have tried several ways e.g. OSCommand,ODI procedure but no luck.
I have executed this command on MS DOS prompt and it executed successfully.So, it should not be a syntax error.
I am using ODI 11g 1.1.3 and windows 7 as operating system.
Regards,
RashmikHow are you executing this ?
Use OdiOsCommand. its should work. You can also use OsCommand tool. If nothing works create a batch file and execute it using OsCommand tool
C:\myfolder\myfile.bat
Bhabani
http://dwteam.in -
Running a dos command from a java application
hello,
I'm trying to execute a batch file from a java application. I tried with:
try
Process proc=Runtime.getRuntime().exec("fop -fo "+iXmlFoFile+" -
svg "+SvgFileName);
}catch (IOException e){System.err.println("Error in conversion of
the Xml FO file into Svg file: "+e);}
and with:
try
Process proc=Runtime.getRuntime().exec("cmd ./c fop
-fo "+iXmlFoFile+" -svg "+SvgFileName);
}catch (IOException e){System.err.println("Error in conversion of
the Xml FO file into Svg file: "+e);}
but i have a IOException: CreateProcess: .... error=2
When I try these line to launch a .exe file it works but not with a .bat file.
I also tried:
String execstr = "fop -fo "+iXmlFoFile+" -svg "+SvgFileName;
String [] commandArray = { execstr };
try {
Runtime.getRuntime().exec(commandArray);
} // end try
catch ( Exception e ) {
System.out.println( e.getMessage() );
e.printStackTrace();
}// end catch
but i got the same exception in java.lang.Win32Process.create
What did i do wrong?Your execution string is a bit more that I want to figure out, but here are a couple ideas:
Is the working directory of any importance? If so you'll need to set that when you do your exec()
I think I remember reading something about batch files that couldn't be kicked off via this method. Perhaps you need to execute the string "start mybatchfile.bat". Seems like you need to do something like that to get a command interpreter to run your batch file. -
Error while running DOS command in Java
Hi all,
I use "runtime" class to execute a DOS command "copy C:\\pathname\\*.* C:\\backupPathname\\". But I saw an error msg "CreateProcess: copy C:\pathname\*.* C:\backupPathname\ error=2".
I did create a folder C:\backupPathname\ before running the DOS command.
Pls help me all Java genius.I ended up writing a small 'c' program and pasing the command in to it from java. The problem seems to be that in dos, unlike unix, the copy command is not a program, rather the command is interpreted by the command.com program.
-
How to run DOS command in Java environment?
Can i run DOS command in Java environment?
I did like this:
Runtime r = Runtime.getRuntime();
r.exec("cmd.exe");
r.exec("set classpath=%CLASSPATH%;.\\tmp")
but failed.
However if I run the java command, it runs successfully.
r.exec("javac Test.java");
r.exec("java Test");
how should I do so that i can run the DOS commands metioned above in Java Environment?
thanks a lot.Have a look at http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
This may help. I wonder if this is ok ?
Runtime r= Runtime.getRuntime();
r.exec("cmd.exe /C set classpath=%CLASSPATH%;.\\tmp\""); -
How to run dos command on java
would java run the dos command ?
if yes ~would you mind give me some example~please~..or just use:
Runtime.getRuntime().exec("cmd /c commandyouwanttouse");
Hope it works! -
Doesn't it get very old, same question about running dos command?
To everyone who is tooo lazy to search.
Process p = Runtime.getRuntime().exec("progname arg1 arg2");
What a wast of everyone's time responding to the same question on how to run a dos command.I think you'll find it's
Runtime.getRuntime().exec(new String[]{"progname", "arg1", "arg2"}); -
Is possible to run a dos command by an AIR application and
obtain the result? For example: can I launch "iireset /status" and
obtain the status of iis?
Grazie!You need to write a small Java Socket Listener, and you also
need to create the Socket in you AIR Application. Before starting
your AIR Application you need to start the SocketListener which
sits listening to the incoming connection from the AIR Application.
But you should use the same port at both the ends(Java and
AIR Application end).
Regards,
Code. -
HOW DO I RUN DOS COMMANDS ON JAVA
I SWEAR, I'LL PAY YA IF YOU HELP ME!!!
Hi, this is the thing:
have you ever run the "time" command on a DOS console?? if you have, you know that it shows the current time, and lets you set a new time.
well, i need to make a java program to open a DOS console and execute the command, and making it able to write in information on the console so it sets a new time.
MY PURPOSE IS NOT JUST WATCHING THE CURRENT TIME!! so please don't tell me to use System.getCurrentTimeMillis() or something like that; i explicitly need to run that DOS command. what's the Java code to do it??
thank you!! and please attach your account # so you get a $50 deposit by the end of the week
thank you!!Thanks a lot, you all guys, but i don't know what's with this thing.... it always throws an IOException, with the following exception stack trace:
java.io.IOException: CreateProcess: temp.bat error=0
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Win32Process.java:63)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:550)
at java.lang.Runtime.exec(Runtime.java:416)
at java.lang.Runtime.exec(Runtime.java:358)
at java.lang.Runtime.exec(Runtime.java:322)
at Tarea.main(Tarea.java:15)and it will come out the same shit over and over. The above case was thrown by the line Runtime.getRuntime().exec("temp.bat") where temp.bat is a file where the only thing written in it is the word "time". and you can change the string parameter of the method exec, and thats what will change in the stack trace above.
I also tried "cmd", "command", and "command.com". With the last one, it opens the command.com application but it freezes and does nothing. With the other two, appears the same old shit from above.
Please help me!!
Thank you... -
Hi,
I am trying to run few dos commands through java using Runtime.exec("command") but I am getting following error
commmand is cd D:\CodeMerge\A\
java.io.IOException: CreateProcess: cd.. error=2
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Unknown Source)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at createDirectory.main(createDirectory.java:24)
Basically what I am looking for is this:
1) My program is in D:\Amit\RM
2) I want to get out to D:\ go to CodeMerge\A\.
3) Create folder with curretn date as name of the folder
Hence I am doing
rTime.exec("cd../..");
rTime.exec("cd D:\CodeMerge\A\");
rTime.exec("mkdir "+date);
Can anybody tell me why I am getting this error
JountyDoublepost.
http://forum.java.sun.com/thread.jspa?threadID=635077&tstart=0
Maybe you are looking for
-
After hours with Apple Tech Support on the phone and 8 re-downloads of 7.1.1 (and older versions starting with 6.04 and up), I've found a fix that worked for me. No more freezing/crashing iTunes or with syncing iPod. No more force quits. Stable as a
-
My laptop may not last much longer, i just bought adobe photoshop elements and wanted to use it, if I download on this laptop and it breaks, can i download to new computer or do i need to rebuy it?
-
I have a layer where on one frame I have 3 dynamic text boxes which I convert to one graphic. These are used to display a value set through actionscript whilst a motion tween fades it in and out. I have called the graphic set1 with names on each of t
-
802.1x Problem After Installing Update 10.4.10
After installing the 10.4.10 update (from 10.4.9), I have started having problems with authenticating using 802.1x over my wireless connection. I enter my login information when prompted, and after a few seconds (when it says "Authenticating..."), it
-
im trying to edit my football highlight tape and i want to know how i can pause the clip for acouple seconds with the oval still on the screen then itll start to play again. ive been looking at some guides but they are the wrong ones if anyone has th