Execute windows command for a network path

hi,
i am trying to execute the following code:
try{
Process process=Runtime.getRuntime().exec(new String[]{"cmd","/c","dir","C:\\Backup"});
InputStream inputStream = process.getInputStream();
BufferedReader bufferreader = new BufferedReader(new
InputStreamReader(inputStream));
String line = bufferreader.readLine();
while(line!=null)
System.out.println(line);
line=bufferreader.readLine();
It works very fine, but when i replace exec() with exec(new String[]{"cmd","/c","dir","\\hfvs4\\storage"}) or with exec(new String[]{"cmd","/c","dir","//hfvs4//storage"}) i am getting any output, the program just runs and terminates.
help me to execute the "dir" on a network path.

Shouldn't that be "\\\\hfvs4\\storage"?thanks a lot. that's a silly point i missed out.

Similar Messages

  • Can't execute windows command in servlet with JDK1.5 and tomcat 5

    Hi all,
    I have a web application which uses a servlet to execute windows commands, such as "mkdir", "mv", and "rmdir". In my servlet, I use java Runtime() class to implement the execution.
    Under jsdk1.4 and tomcat 4, it is fine for the servlet to execute those command. But uncer jdk1.5 and tomcat 5, it gives the following error:
    error to execute a command: java.io.IOException: CreateProcess: mkdir c:\m7q28 error=2
    java.io.IOException: CreateProcess: mkdir c:\m7q28 error=2
    Please help me if you have any idea. Thanks.

    And be sure to read this:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Windows command for Patch installation

    Hi!
    We are having some difficulty understanding the Windows command for installing a patch.
    We read the readme, but cannot quite follow. Can someone please provide this command?
    Version: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
    Thanks!

    PavanG wrote:
    You can use the below command to apply the patch.
    opatch apply
    You will need to run this command from the patch folder after setting the Oracle Home and Oracle Sid.There are other options to opatch - such as napply. Better to find out what the OP is having difficulty with before throwing out a one-size-fits-all solution.

  • Executing external commands(vbscript from network drive)

    Hello All,
    There is a client requirement where a certain number of steps need to be automated as a background job. The current manual process is such that first a vbscript is run, which creates a temporary folder and connects to a FTP location and pick data and dump it into this temporary folder on the network drive. Then a standard SAP program uses this file from the defined path and is executed. Then another vbscript is run, which basically archives the files to a different folder. These steps need to be automated.
    Now we can use the cscript command in DOS to execute a .vbs script file. but this will not work with GUI_EXEC as this will fail in background. Will SXPG_COMMAND_EXECUTE/SXPG_CALL_SYSTEM fucntion modules work in this case ? I have not used them, so will they execute the command on the presentation server as I am guessing these work on the application server with the command created in SM69 ?
    Thanks and Regards,
    Sachin

    hi all,
    You don't have to create a System Commands in transaction SM69 to be able to execute the VBScript or other script within the program in background mode.
    When calling function "WS_EXECUTE" just add the "In Background Task" at the end to execute the VBscript or other scripts.
    This  extra line "In backround task" should not raise the exception
    CL_GUI_FRONTEND_SERVICES======CP.
    it should look like this.
    data: commandline(1000).
    commandline = 'P:\sapfrontend.vbs'.
      call function 'WS_EXECUTE' in BACKGROUND TASK
           exporting
                commandline    = commandline
                program        = 'WSCRIPT.EXE'
           exceptions
                frontend_error = 1
                no_batch       = 2
                prog_not_found = 3
                illegal_option = 4
                others         = 5.

  • Execute windows command line to a file

    Hi,
    I would like to run a windows command line from Java and output the result to a file.
    eg.
    cmd> mycommand hello > output.txt
    in windows ">" is to output the result to a file.
    I've tried
    String command  = "mycommand hello > output.txt";
    Process process = Runtime.getRuntime().exec(command);But that exec() didn't output to a file.
    Can someone give me an example on how to do this?
    Thanks

    You are falling for one of the traps described here. The redirection operator '>' has to be interpreted by a shell or command processor. On windows this would be
    String command  = "cmd.exe /C mycommand hello > output.txt";and on Linux this would beString command  = "sh -c mycommand hello > output.txt";You should read all 4 sections of the traps article and implement ALL the recommendations or you will be back here again.

  • Help with executing windows command in java

    hi, i am trying to execute dos command in java. currently i am trying simply to create a folder in the current directory.
    here is the code snippet:
    try {
    Process p = Runtime.getRuntime().exec("md myFolder");
    } catch (IOException io) {
    io.printStackTrace();
    i have also tried using "mkdir" instead of "md". but my code just throws an exception that says:
    java.io.IOException: CreateProcess: md myFolder error=2
    what have I done wrong? thanks in advance

    try {
    Process p = Runtime.getRuntime().exec("cmd /c
    mkdir myFolder");
    catch (IOException io) {
    io.printStackTrace();hey! that code worked out perfectly. so "cmd" is needed to run dos commands? i searched through the net, but most of the examples that i were able to find did not include "cmd".
    if it wouldn't be too much trouble, what is the option "/c" for?
    i would also like to add that "mkdir" also works. The problem was the missing "cmd /c". Thanks guys for your help! I really appreciate it.

  • Remotely execute batch commands for AD users?

    Alright, so I haven't found this anywhere, but is there a way to remotely execute commands for AD users?Eg. I have a user with an invalid signature in Outlook. I originally wrote up a script that would apply these signatures and set them as default on user logon, but I also made versioning available in my script, and I don't want to create an entire new version just because of a single signature, so instead I would prefer to use a command like "xcopy "\\server\deployed\signatures\%username%\signature.htm" /q /y /z" Is it possible for me to do it remotely?PS.Sorry if the question may sound stupid, I just haven't done something like this before.
    This topic first appeared in the Spiceworks Community

    Alright, so I haven't found this anywhere, but is there a way to remotely execute commands for AD users?Eg. I have a user with an invalid signature in Outlook. I originally wrote up a script that would apply these signatures and set them as default on user logon, but I also made versioning available in my script, and I don't want to create an entire new version just because of a single signature, so instead I would prefer to use a command like "xcopy "\\server\deployed\signatures\%username%\signature.htm" /q /y /z" Is it possible for me to do it remotely?PS.Sorry if the question may sound stupid, I just haven't done something like this before.
    This topic first appeared in the Spiceworks Community

  • Issue to write/execute AT-commands for a 3G modem

    Dear community,
    For the past month, I'm searching for some help on this topic without success, "you are my last hope"
    After modification of the PPP parameters under network preferences (according the clear archive from apple support on this topic), the terminal windows is poping up without any problem.
    Then... I can't write anything on this terminal !!! The only actions I'm able to perform is cancel or continue button. I also press the Return key as apple support mentioned (issue for 10.2 or earlier), nothing.
    The test was done on a early 2010 macbook 13 and the same on a mid 2010 macbook 15, the same issue.
    - Am I doing something wrong or mac os restricted this com protocol?
    - Is there a way to command the modem trough the main computer terminal (which is working properly)?
    Thank you in advance!

    You've probably solved this problem long ago, but I came across this thread a couple weeks ago when trying to do the same and thought I post this .vi for future users.  This code is for a multitech MT5656ZDXV modem, but I think the AT commands are generic enough to be used with any voice modem. Hardware configuration requires and audio cable running from the PC speaker to the modem mic port.  Also, I had to use a Konnex Office Konnector telephone line A/D which required me to manually pick up a handset; the software prompts the user to do this.  Fancier A/Ds should eliminate the need for this and I have one on order.  If you have an analog phone line then there should be no need to use an A/D or manually pick up the phone.
    Attachments:
    modem_speakerphone.vi ‏21 KB
    Sound Player.vi ‏17 KB

  • CLI commands for remote network

    I have a 800 router connected to our HQ via site-to-site vpn.
    I have commands i wish to run from the CLI but cannot get them to work.
    Pings fails from the CLI if using 'ping x.x.x.x' but are successful if using 'ping x.x.x.x source x.x.x.x'
    I am guessing all local CLI commands are trying to direct via the WAN as default, how can I resolve this for commands i wish to direct via the VPN.
    The command I really want to run is 'logging host x.x.x.x', with the syslog host being in HQ via the vpn tunnel

    IOS is always choosing interface which is closest to destination (i.e. consults routing table), when sourcing traffic from the box. 
    There are several commands (usually one-two per feature to override this behavior). 
    For the command you're looking for.
    Spoke1(config)#logging source-interface ?
    Async Async interface
    Auto-Template Auto-Template interface
    BVI Bridge-Group Virtual Interface
    CDMA-Ix CDMA Ix interface
    CTunnel CTunnel interface
    Dialer Dialer interface
    Ethernet IEEE 802.3
    GMPLS MPLS interface
    LISP Locator/ID Separation Protocol Virtual Interface
    LongReachEthernet Long-Reach Ethernet interface
    Loopback Loopback interface
    MFR Multilink Frame Relay bundle interface
    Multilink Multilink-group interface
    Null Null interface
    Serial Serial
    Tunnel Tunnel interface
    Vif PGM Multicast Host interface
    Virtual-PPP Virtual PPP interface
    Virtual-Template Virtual Template interface
    Virtual-TokenRing Virtual TokenRing
    vmi Virtual Multipoint Interface

  • Execute Windows Command

    How to execute follow commnad from java on Windows System and also get it input
    systeminfo | find "OS Name"Thanks.

    wearetherock wrote:
    I found solution , thank you very much.Please post your 'solution' so as to enlighten others who have the same problem?
    Edited by: sabre150 on Oct 31, 2008 10:49 AM
    What an idiot. He obviously never followed any of the recommendations given in his equivalent Linux thread - http://forums.sun.com/thread.jspa?threadID=5339913&messageID=10466185#10466185

  • The underlying connection was closed: An unexpected error occurred on a receive..Exception.Message - while executing powershell command for sharepoint online site

    " +The underlying connection was closed: An unexpected error occurred on a receive..Exception.Message " OR sometimes
    "The remote server returned an error: (503) Server Unavailable..Exception.Message"
    Getting exception above when performing various operation (site coll creating, group creation, adding users to group) for sharepoint online (Office 365) site using powershell script.
    I want to create 3500 site collections using PS script. In-between getting above exception so it will skip one site collection creating and working again. for eg. after creating 11 site coll, script will through above exception and so 12th site coll will
    not be create but working fine from 13 and so on...

    Remote server seems working to me...any additional check?
    if problem with remote server then may be loop to create site provisioning should not start again..Right?
    any idea?

  • Download Firefox Installer for Windows xp for disconnected networks

    Hello. I want to obtain a complete install package (exe, etc) of Firefox 18 or 19 as my preferred browser on non-internet facing nodes. I have read that installers are calling out for updates upon completion and the nodes in questions cannot connect to the internet. I am looking for a complete/full install of FF 18 or 19 as mentioned above. I am not a local admin on the Internet facing pc that is being used to pull down the binaries. Thanks for any feedback.

    WOW! Thanks for the very prompt reply. It appears to be a full install as you had mentioned. I do receive an error stating "the proxy server is refusing connections" as expected but the browser appears to be complete with its install.
    I will need to apply "DISA lockdowns" for the Firefox settings to be accepted by computer security. I am required to follow guidelines, automate the settings, have it apply to all users, and generate a report of these types of lockdowns.
    If you have further information or pointers to that type of information it would be very much appreciated.
    Thanks again for the very quick repsonse. You saved me valuable time.

  • Equivalent  for execute immediate command in maxdb

    hi all,
    like in oracle for executing the sql_query, we have execute immediate command.
    for e.g.. in oracle
    L_SQL ='SELECT * FROM EMP';
    EXECUTE IMMEDIATE L_SQL;
    what will be the command for execute immediate in MaxDB??
    like in MaxDB
    L_SQL = 'SELECT * FROM EMP';
    Now How can i execute the above l_sql variable in MaxDB.
    thanks, Bhupinder

    Hi Bhupinder,
    the following code snippet should do the job
    [code]
    CREATE DBPROC EXAMPLE
    AS
    VAR statement1 char(100);
    SET statement1 = 'SELECT * from DBA.DUAL';
    TRY
        EXECUTE statement1;
    CATCH IF $rc <> 100
         THEN STOP ($rc, 'unexpected error');
    [/code]
    Best regards,
    Marco

  • Unable to set the ip address for hosted network client after creating WIFI hotspot

    Original Title: INTERNET CONNECTIVITY PROBLEM WITH MY LAPTOP WIFI HOTSPOT
    HI all
    I am able to use internet connection from my lap hotspot, when the internet source is Public or private wifi.
    so I know the cmd window commands for hotspot and settings of client(sharing to hosted network client, assigning IP address etc.,)
    but the problem I am facing is slight different
    I am using my cdma wireless broadband datacard as my source internet connection(Reliance netconnect +)
    when I try to create hotspot for this, as usual I am able to create the hotspot and able to share the internet to hostednework client.
    but I am unable to set the ip address for hosted network client, if I try to set ip 192.169.137.1 and 255.255.255.0
    as soon as I close the window, the ip address also disappears
    when connect my android phone to that hotspot, it is able to connect but there is no internet connectivity.
    when I check the hostednetwork client for packet transmission, both sent and received packet is happening., I mean transmitting
    so what cause the failure in internet connectivity but success in hotspot connectivity?
    check the screen shots...
    can u help me..
    its little complicated

    Hi,
    Please make sure the Ad hoc connection IP adress is at the same range with your local connection. In addition, how about recreate the ad hoc connection for test, please have a try.
    If problem persists, please use Network troubleshooter in Action Center to fix this problem for test.
    Roger Lu
    TechNet Community Support

  • Wm-experiments: pytiler - Tiling/window management for floating WMs

    I've created a few little tools and things to experiment with WMs recently and I'm slowly putting them into this git repository:
    http://github.com/iphitus/wm-experiment … er/pytiler
    The first one is pytiler. It's a usable proof of concept window tiler for any standards compliant floating (or tiling) WM. It runs as a daemon, continually managing/arranging windows. This gives the same behaviour as if you're running a tiling WM - in your floating WM. If you think about it, floating WM's do very little arrangement/positioning, so they don't mind if an external tool does it for them. Alternatively it can be called to just tidy up/layout windows without the daemon.
    I realise there is already the "Poor Man's Window Tiler" however it has a few pitfalls
    - Can only be called once off
    - Parses and executes external commands for it's window control.
    pytiler uses libwnck, which can either be found in gnome-python-desktop (gnome dep) or libwnck-python (AUR, no gnome dep).
    I no longer use pytiler and don't have the time to develop/maintain it so I'm hoping someone here will find it useful or wish to extend it further.
    Last edited by iphitus (2009-07-25 01:26:27)

    sand_man wrote:
    Tyriel wrote:I really love the idea of this.  Nice work
    Search the forums for stiler
    I have mentioned stiler above, however this implementation does more than a few things differently, ie, 'continual' management of windows and not parsing the output of externally called programs.
    Last edited by iphitus (2009-07-29 12:13:29)

Maybe you are looking for