Clock command (global vs exec)

hi all,
clock command is available in both global and exec modes ,
I am confused about the difference , 
can someone please clarify it with me ?

"assume you have configured clock in exec mode to be exactly your local time"  
That would be fine, until daylight savings time, at which point you would need to manually change the clock on all your switches and routers.  
If you set the clock in exec mode first, then set the timezone, time would change depending on the timezone that was set, which would require re configuring the time.
Correct steps in setting time would be:
-> configure the correct time zone.  (example: Router(config)# clock timezone CST -6)
-> configure device to adjust time for daylight saving time. (example: Router(config)# clock summer-time CDT recurring)
->  Set the devices's clock in exec mode.  (example: Router# clock set 18:00:00 Oct 26 2014)
A couple of benefits of setting the correct time are: Log files display the correct time stamp(if service timestamps is applied to log), using the kron scheduler to schedule commands to be ran at a specific time.
Hope this helps...

Similar Messages

  • Problem to execute cvs command using Runtime.exec method

    Hello,
    I want execute this cvs command, with this options:
    cvs -d :pserver:[email protected]:/home/cvs/cvsroot rlog -S -d "2007/05/01<now" Project
    I tried to execute with Runtime.exec() :
    Runtime.exec("cvs -d :pserver:[email protected]:/home/cvs/cvsroot rlog -S -d \"2007/05/01<now\" Project");
    But I have an error because the smaller character is interpretate as a redirection, no as a smaller symbol.
    How I can do to use this command with Runtime.exec ?
    Thanks.
    Regards.

    Sorry,
    I had a typing mistake.
    I want say:
    Runtime.exec("cvs -d :pserver:[email protected]:/home/cvs/cvsroot rlog -S -d \"2007/05/01<now\" Project");
    Regards.

  • External commands in runtime exec

    Im trying to run commands from the Sleuthkit in a java GUI. These commands have no problem running from the konsole as all the paths etc. have been set up, but when I try to run them with the java runtime exec() they wont work. Similarly,i run standard linux commands in this gui aswell and they run without problem.
    Any ideas whats weong?
    Thanks.

    You didn't tell us exactly what you're doing.Its a forensic GUI that runs konsole based commands
    and displays the ouput in a JText areaThat tells us nothing useful. By "exactly what you're doing," I mean the Java code and the command it's exec()ing.
    >
    You didn't tell us what "doesn't work" means.The 'basic' linux commands work fine in the gui, its
    just the sleuthkit ones that wont run or return
    anything when executed using the runtime exec(). Even
    though running these commands in a konsole works
    fine. THis means all paths have been set.
    Any ideas on a different way to run them or should I
    include more than just the command used on the
    konsole?That still doesn't tell us what "doesn't work" means.
    My previous response still applies.

  • Help: use command "run" and "exec", no output

    I create a script file Test.sql, and type "run d:\test.sql" in ttisql's command prompt, but there is no output, not even any error messages.
    Command> run d:\test.sql;
    Command>
    I try to use "Prepare" and "Exec", still no output
    Command> prepare 1 select * from employee;
    Command> exec 1;
    Command>
    ttisql looks recognize these commands, but it doesn't execute them. Who knows the reason? thanks.

    Hi,
    I create a script file Test.sql, and type "run d:\test.sql" in ttisql's command prompt, but there is no output, not even any error messages.What SQL statements are in Test.sql? To see more verbose output from ttIsql, try increasing verbosity. The default is 2. The highest (most verbose) is 4.
    Command>verbosity;
    verbosity = 2
    Command> verbosity 4;
    The command succeeded.
    try to use "Prepare" and "Exec", still no outputTry adding a fetchone or fetchall command to retreive the result. e.g.
    Command> prepare 1 select * from emp;
    Command> exec 1;
    Command> fetchone;
    < 7369, SMITH, CLERK, 7902, 1980-12-17 00:00:00.000000, 800.0000, <NULL>, 20 >
    1 row found.
    Command> fetchone;
    < 7499, ALLEN, SALESMAN, 7698, 1981-02-20 00:00:00.000000, 1600.000, 300.0000, 3
    0 >
    1 row found.
    Command> fetchall;
    < 7521, WARD, SALESMAN, 7698, 1981-02-22 00:00:00.000000, 1250.000, 500.0000, 30
    >
    < 7566, JONES, MANAGER, 7839, 1981-04-02 00:00:00.000000, 2975.000, <NULL>, 20 >
    < 7654, MARTIN, SALESMAN, 7698, 1981-09-28 00:00:00.000000, 1250.000, 1400.000,
    30 >
    < 7698, BLAKE, MANAGER, 7839, 1981-05-01 00:00:00.000000, 2850.000, <NULL>, 30 >
    < 7782, CLARK, MANAGER, 7839, 1981-06-09 00:00:00.000000, 2450.000, <NULL>, 10 >
    < 7788, SCOTT, ANALYST, 7566, 1987-04-19 00:00:00.000000, 3000.000, <NULL>, 20 >
    < 7839, KING, PRESIDENT, <NULL>, 1981-11-17 00:00:00.000000, 5000.000, <NULL>, 1
    0 >
    < 7844, TURNER, SALESMAN, 7698, 1981-09-08 00:00:00.000000, 1500.000, 0.000000e+
    00, 30 >
    < 7876, ADAMS, CLERK, 7788, 1987-05-23 00:00:00.000000, 1100.000, <NULL>, 20 >
    < 7900, JAMES, CLERK, 7698, 1981-12-03 00:00:00.000000, 950.0000, <NULL>, 30 >
    < 7902, FORD, ANALYST, 7566, 1981-12-03 00:00:00.000000, 3000.000, <NULL>, 20 >
    < 7934, MILLER, CLERK, 7782, 1982-01-23 00:00:00.000000, 1300.000, <NULL>, 10 >
    12 rows found.
    Command>
    Good luck.
    Simon

  • Form data - to command - for verification - exec

    I'm attempting to assign entered form data into an array, to generate a list
    of command line commands from the form data, and pass the array to a
    verification page for display. After the displayed and verified information has
    been approved , press a submit button to spawn xterms that get passed the
    information in the array, the command list, for execution. I'm having a
    problems capturing and relaying the data between pages. Currently, the
    information(the command list being generated in variable ${myMap}) is
    being displayed correctly in the VerificationPage.jsp output but not displayed
    correctly (nothing from the ${myMap} variable is displayed)when
    ProcessingPage.jsp is loaded. I would appreciate any help offered. Below is
    the code I'm using.
    File one:
    data/form input
    File two: VerifcationPage.jsp - assign the consolidated command into myMap array and display it to screen
    <c:set scope="application" var="counter" value="0"/>
    <c:forEach var="rel" items="${paramValues.rel}" begin="0" step="1">
         ${myMap} bldautox ${param.phasecmd} -s ${param.submitter} -o r${paramValues.rel[counter]}${param.oldtreeext}${param.oldtreespin} -n r${paramValues.rel[counter]}${param.newtreeext}${param.newtreespin}
         <br>
         <c:set var="counter" value="${counter + 1}"/>
    </c:forEach>
         <br>
    <c:forEach items="${paramValues.myMap}" begin="0" step="1">
         <c:out value="${myMap[count]}" />
    </c:forEach>
         <input type="submit" name="submitbldreqs" value="Submit">
        </form>
    File three-the ProcessingPage.jsp - display each indice of myMap variable and be able to submit for command line execution
    <c:forEach var="myMap" items="${paramValues.myMap}" begin="0" step="1">
         <c:out value="${param.myMap[cntr]}" />
         <c:set var="cntr" value="${cntr + 1}"/>
    </c:forEach>
         <br>
         <% String cmd = "0"; %>
    <%-- Desired executable Runtime.getRuntime().exec("/usr/bin/xterm -e" + {myMap}[cntr]); --%>
         <% Runtime.getRuntime().exec("/usr/bin/xterm"); %>
      </body>

    You put newlines in by pressing the enter key a couple of times.
    see?
    For the rest of it, there is a big handy button with "code" labelled on it.
    [code[/i]]
    // put your code between tags like these.
    [code[/i]]
    That post is a completely unreadable mess. I suggest you try again.

  • Problem: Using "msg" command with "System Exec.vi"

    I'm attempting to write some LabView code that takes advantage of the "System Exec.vi". At the moment, I've tried using it to ping machines, return the ipconfig and run through the example code that NI provides.
    I would like to use the "msg" command used on Windows operating systems to send out a message to multiple machines on our network at once. Warning them we're about to update a program and they should log-off, things like that.
    I tried using the "msg" command in LabView keeps returning errors. I also wrote a quick batch file as follows:
    @echo on
    cd c:\Windows\System32\
    msg.exe /server:localhost * test
    When I launch the batch from windows, it executes. When I launch it from LabView (using the System Exec.vi) it fails.
    Potential Quirks:
    I discovered in a different location that in order for a machine to receive these messages they need to have a registry entry in:
    "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" and have a DWord called "AllowRemoteRPC" = 1.
    Note that "/server:localhost" could be "/server:anycomputer" and the " * " is used as a wildcard which sends a message to anyone who is logged onto that machine. Also note that "test" is the message to be sent.
    Any ideas why I'm having a problem?
    tl;dr: "System Exec.vi" won't run the "msg" command. Why is this?
    - Mike
    ~~~~~~~~~~~~~~
    Current Setup:
    LabView 2010
    Windows 7
    Solved!
    Go to Solution.

    -> What versions of labview and windows are you on?
    LabView 2010 and Windows 7.
    -> Have you ever sent any commands out, or is msg the only one you've tried so far?
    I've successfully used the 'ping' command and also returned a standard 'help' command to LabView.
    -> Finally, in tools>>options, you may need to change your access settings under VIserver and Webserver.
    My VI server settings are allowing everything except "Show VI Scripting Functions, properties and methods"
    I have nothing configured for a web server, since I didn't plan on using it for this. Unless it has some sort of connection that I am missing.
    I'm attempting a work-around where LabView will generate a batch file to run from the desktop instead, since it seems that something is getting lost in translation between LabView and the command-prompt.
    - Mike
    ~~~~~~~~~~~~~~
    Current Setup:
    LabView 2010
    Windows 7

  • Running CMD command from process.exec

    I've been chopping this code up so forgive me if this is a mess, however I cannot figure out why this command simply will not work. It never seems to attempt to sign the jar files. I've also tried to sign the jar file by using an output stream. I can run the System.out of the payload from the CMD and it works fine.
    When this method is executed it seems to loop over like nothing is happening.
    private void signJar(String jarPath)
                   String payload = "\"c:\\program files\\java\\jdk1.6.0_17\\bin\\jarsigner.exe\" -keystore \"" + ksPath + "\" -storepass " + ksPW + " \"" + jarPath + "\" " + ksAlias;
                   try {
                        Process proc = Runtime.getRuntime ().exec("cmd /c " + payload);
                        InputStream inputstream = proc.getInputStream();
                        InputStream errorstream = proc.getErrorStream();
                        InputStreamReader inputstreamreader = new InputStreamReader(inputstream);
                        InputStreamReader errorstreamreader = new InputStreamReader(errorstream);
                        BufferedReader inputreader = new BufferedReader(inputstreamreader);
                        BufferedReader errorreader = new BufferedReader(errorstreamreader);
                        while ((line = inputreader.readLine()) != null) {
                             d.asyncExec(new Runnable() {
                                  public void run(){
                        l.setText(line + "\n" + l.getText());
                        while ((line = errorreader.readLine()) != null) {
                             d.asyncExec(new Runnable() {
                                  public void run(){
                             l.setText(line + "\n" + l.getText());
                        errorreader.close();
                        inputreader.close();
                        return;
                        catch(IOException e)
                             e.printStackTrace();
                             return;
              }

    sabre150 wrote:
    You probably have a deadlock since your code falls for at least 2 of the traps described in the 4 sections of [http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html|http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html].
    Thanks, I checked this out and decided to implement one of the methods he had, however, now I am getting an illegal argument exception. I think it is because of my payload, but I am not sure how to fix it. I know everything is formatted properly to input it in the console manually.
    private void signJar(String jarPath)
                   String payload = "\"c:\\program files\\java\\jdk1.6.0_17\\bin\\jarsigner.exe\" -keystore \"" + ksPath + "\" -storepass " + ksPW + " \"" + jarPath + "\" " + ksAlias;
                   String cmds[] = {"cmd","/c",payload};
                   if (cmds.length < 1)
                     System.out.println("USAGE: java GoodWindowsExec <cmd>");
                     System.exit(1);
                 try
                     String[] cmd = new String[3];
                         cmd[0] = "cmd.exe" ;
                         cmd[1] = "/C" ;
                         cmd[2] = cmds[2];
                     Runtime rt = Runtime.getRuntime();
                     System.out.println("Execing " + cmd[0] + " " + cmd[1]
                                        + " " + cmd[2]);
                     Process proc = rt.exec(cmd);
                     // any error message?
                     StreamGobbler errorGobbler = new
                         StreamGobbler(proc.getErrorStream(), "ERROR");           
                     // any output?
                     StreamGobbler outputGobbler = new
                         StreamGobbler(proc.getInputStream(), "OUTPUT");
                     // kick them off
                     errorGobbler.start();
                     outputGobbler.start();
                     // any error???
                     int exitVal = proc.waitFor();
                     System.out.println("ExitValue: " + exitVal);       
                 } catch (Throwable t)
                     t.printStackTrace();
              }Updated with different code still same error
    EDIT: I should pay closer attention and stop trying to copy and paste code. I see where he says you can't use it like the command line...

  • Running System commands using Runtime.exec()

    I'm trying to run an example from "The Java Programming Language" book by Arnold, Gosling and Holmes. I'm trying to run a system level command and get the results. The code looks like:
    public static String[] runCommand(String cmd) {
    String[] outputData= null;
    String[] cmdArray = {"/usr/bin/ls", "-l", "/tmp"};
    try {
    Process child = Runtime.getRuntime().exec(cmdArray);
    InputStream in = child.getInputStream();
    InputStreamReader reader = new InputStreamReader(output);
    BufferedReader = new BufferedReader(reader);
    // read the commands output
    int counter = 0;
    String line;
    while ((line = input.readLine()) != null)
    outputData[counter++]= line;
    if (child.waitFor() != 0){  // error when it's not 0       
    System.out.println("Couldn't run the command.");
    System.out.println("It produced the following error message : " + child.exitValue());
    outputData = null;
    } catch (Exception e){
    System.out.println("It got here!");
    System.out.println("It produced the following error message : " + e.getMessage());
    outputData = null;
    return outputData;
    It gets to the while line, trys to run the input.readLine() and kicks out the exception that looks like:
    It got here!
    It produced the following error message : null
    I know it gets to the input.readLine() because I had a whole lot more try blocks in there, but for simplicity left it out (so it look like the code in the book, which I tried originally). When I run the same command from the command line (on our Sun Solaris 2.8 system) I get results back. I'm not sure what I'm doing wrong. Any help would be greatly appreciated. Thanks.

    Hi, duffymo, hope you can help me. Consider this servlet code:
    String theCommand = "csh /export/home/gls03/sasstuff/runsas.csh /export/home/g
    ls03/sasstuff/gary2.sas";
    //Create a parent Process for the sas program subprocess:
    Process p = rt.exec(theCommand);
    System.out.println("after call to rt.exec(theCommand)");
    Here is the runsas.csh script:
    #!/bin/csh
    setenv LD_LIBRARY_PATH /opt/sybase/lib:/usr/lib:/usr/openwin/lib:/opt/SUNWspro/S
    C2.0.1
    setenv SASROOT /usr/local/CDC/SAS_8.2
    setenv XKEYSYMDB /usr/local/CDC/SAS_8.2/X11/resource_files/XKeysymDB
    $SASROOT/sas -sasuser /hpnpages/cgi-bin/applinks/hospcap/tmp $1
    The execution never gets to the println statment, here is the error:
    class java.io.IOException Exception. Message: CreateProcess: csh /export/home/g
    ls03/sasstuff/runsas.csh /export/home/gls03/sasstuff/gary2.sas error=2
    java.io.IOException: CreateProcess: csh /export/home/gls03/sasstuff/runsas.csh /
    export/home/gls03/sasstuff/gary2.sas error=2
    at java.lang.Win32Process.create(Native Method)
    at java.lang.Win32Process.<init>(Win32Process.java:66)
    at java.lang.Runtime.execInternal(Native Method)
    at java.lang.Runtime.exec(Runtime.java:551)
    at java.lang.Runtime.exec(Runtime.java:477)
    at java.lang.Runtime.exec(Runtime.java:443)
    at sasRunnerNew.doPost(sasRunnerNew.java:103)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
    pl.java:262)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:21)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
    va:27)
    at us.ny.state.health.hin.hinutil.HinFilter.doFilter(HinFilter.java:124)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja
    va:27)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
    rvletContext.java:2643)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
    pl.java:2359)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    The command runs fine in unix.
    I've also tried using these as arguments to exec:
    String theCommand = "/bin/csh /export/home/gls03/sasstuff/runsas.csh /export/home/gls03/sasstuff/gary2.sas";
    String[] theCommand = {"csh", "/export/home/gls03/sasstuff/runsas.csh", "/export/home/gls03/sasstuff/gary2.sas"};
    These generate the same error. I'm thinking this is a sas-specific problem.
    Thanks for any help. Gary

  • Running interactive command with Runtime.exec

    I'm trying to run a command via the Runtime.exec interface.
    Occasionally, the command needs to prompt for additional information. The response depends on the specific configuration, however, the command returns a list of options and then waits for a response.
    However, when the command waits for the response, my Java app hangs.
    After I call Runtime.exec, I create 2 threads to consume the contents of stderr and stdout. I then start them and call proc.waitFor()
    I would expect to see the output of the command in the stdout stream even though the command hasn't exited. I had hoped to parse the output to determine the necessary response. However, the calls to read the contents of the stdout and stderr streams block and I never see any output.
    How can I get access to the contents of those streams while the command is still running? Is this supported through the Runtime.exec interface?
    Thanks,
    Shawn

    This article should help:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Problem  in  executing dos command from runtime.exec(String command);

    Hi
    i have wriiten a code for running command of DOS-Promt
    try
         rnt1 = Runtime.getRuntime();
                                  proc1= rnt1.exec("myb");//myb is a batch file      and proc1 is process class instance
                                                                try
                                  proc1.waitFor();
                                  catch (InterruptedException e)
                             System.out.println("InterruptedException raised: "+e.getMessage());
                   catch (IOException ioe)
              System.out.println("IOException raised: "+ioe.getMessage());
    But it is giving error while running:
    this is showing as an IO exception
    CreateProcess: myb error=0
    Please help me how to proceed
    Thanks

    There are 2 possible reasons (perhaps concurrent):
    1. The file to be executed is not in the same path of your application, and you MUST specify its whole absolute path as exec() argument;
    2. The file to be execute is really (as you call it) a DOS batch file, and then it HAS TO BE NAMED (and called) myb.BAT or (under NT/2000) myb.CMD; WinDOS is Not Unix (WNU): extensions rule!!!

  • Argument of a command called by exec...

    Hi, I want exec this command:
    gpg -e -s -r USERNAME batch yes --passphrase-fd 0 FILE
    for ex.: USERNAME=test and FILE=/home/test/clear file/file.
    so the String FILE contains a space (from clear and file). If I use:
    Process proc = Runtime.getRuntime().exec("gpg -e -s -r"+NAME+" --batch --yes --passphrase-fd 0 "+FILE);
    the software gpg return an error because it see FILE as two element.
    With the normal shell the problem is solved typing:
    gpg -e -s -r test batch yes --passphrase-fd 0 "/home/test/clear file/file" so the
    shell assign the string "/home/test/clear file/file" at the same argv of the process gpg.
    But with java I don't know how solve this problem. There is a method for forcing (when a process
    is executed) the argument of the process?
    Thank for any help very much and best regards.
    FM

    Just quote the string that contains the file:
    Process proc = Runtime.getRuntime().exec("gpg -e -s -r"+NAME+" --batch --yes --passphrase-fd 0 \""+FILE +"\"");This way, the FILE variable is always outputted to the shell in quotes.
    Tuomas Rinta

  • 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...thanks

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

  • Java exec spawns command window

    Hello,
    I am using JRE 1.4.2 (Eclipse runtime environment). Whenever I execute the following command:
    System.getRuntime().exec("<some command>");
    I am getting a Command Window that pops up while the process executes and closes afterwords.
    Is there any way to prevent this command window from appearing. I have chained all Error and Output streams within the java program but no luck. I guess the only other solution is to not make the exec calls by making native calls from the java program, but that would be a huge undertaking.
    Thanks in advance.

    Yes, I think you are correct.
    When I do the same with say calc.exe or notepad.exe, I do not get this dos command prompt.
    The command that I am trying to execute here is PCLI.exe (for PVCS). Do you have an idea of how I can deal with this program so that I do not get that annoying comand prompt?

  • Runtime.exec() fails sometime to execute a command

    Hello,
    I have a program thats using Runtime.exec to execute some external programs sequence with some redirection operators.
    For e.g, I have some command as follows;
    1 - C:\bin\IBRSD.exe IBRSD -s
    2 - C:\bin\mcstat -n @punduk444:5000#mc -l c:\ | grep -i running | grep -v grep |wc -l
    3 - ping punduk444 | grep "100%" | wc -l
    ...etc.
    These command in sequence for a single run. The test program makes multiple such runs. So my problem is sometimes the runtime.exec() fails to execute some of the commands above (typically the 2nd one). The waitFor() returns error code (-1). That is if I loop these commands for say 30 runs then in some 1~4 runs the 2nd command fails to execute and return -1 error code.
    Can some one help me out to as why this is happening? Any help is appreciated
    Thanks,
    ~jaideep
    Herer is the code snippet;
    Runtime runtime = Runtime.getRuntime();
    //create process object to handle result
    Process process = null;
    commandToRun = "cmd /c " + command;
    process = runtime.exec( commandToRun );
    CommandOutputReader cmdError = new CommandOutputReader(process.getErrorStream());
    CommandOutputReader cmdOutput = new CommandOutputReader(process.getInputStream());
    cmdError.start();
    cmdOutput.start();
    CheckProcess chkProcess = new CheckProcess(process);
    chkProcess.start();
    int retValue = process.waitFor();
    if(retValue != 0)
    return -1;
    output = cmdOutput.getOutputData();
    cmdError = null;
    cmdOutput = null;
    chkProcess = null;
    /*******************************supporting CommandOutputReader class *********************************/
    public class CommandOutputReader extends Thread
    private transient InputStream inputStream; //to get output of any command
    private transient String output; //output will store command output
    protected boolean isDone;
    public CommandOutputReader()
    super();
    output = "";
    this.inputStream = null;
    public CommandOutputReader(InputStream stream)
    super();
    output = "";
    this.inputStream = stream;
    public void setStream(InputStream stream)
    this.inputStream = stream;
    public String getOutputData()
    return output;
    public void run()
    if(inputStream != null)
    final BufferedReader bufferReader = new BufferedReader(new InputStreamReader(inputStream), 1024 * 128);
    String line = null;
    try
    while ( (line = bufferReader.readLine()) != null)
    if (ResourceString.getLocale() != null)
    Utility.log(Level.DEBUG,line);
    //output += line + System.getProperty(Constants.ALL_NEWLINE_GETPROPERTY_PARAM);
    output += line + "\r\n";
    System.out.println("<< "+ this.getId() + " >>" + output );
    System.out.println("<< "+ this.getId() + " >>" + "closed the i/p stream...");
    inputStream.close();
    bufferReader.close();
    catch (IOException objIOException)
    if (ResourceString.getLocale() != null)
    Utility.log(Level.ERROR, ResourceString.getString("io_exeception_reading_cmd_output")+
    objIOException.getMessage());
    output = ResourceString.getString("io_exeception_reading_cmd_output");
    else
    output = "io exeception reading cmd output";
    finally {
    isDone = true;
    public boolean isDone() {
    return isDone;
    /*******************************supporting CommandOutputReader class *********************************/
    /*******************************supporting process controller class *********************************/
    public class CheckProcess extends Thread
    private transient Process monitoredProcess;
    private transient boolean continueLoop ;
    private transient long maxWait = Constants.WAIT_PERIOD;
    public CheckProcess(Process monitoredProcess)
    super();
    this.monitoredProcess = monitoredProcess;
    continueLoop =true;
    public void setMaxWait(final long max)
    this.maxWait = max;
    public void stopProcess()
    continueLoop=false;
    public void run()
    //long start1 = java.util.Calendar.getInstance().getTimeInMillis();
    final long start1 = System.currentTimeMillis();
    while (true && continueLoop)
    // after maxWait millis, stops monitoredProcess and return
    if (System.currentTimeMillis() - start1 > maxWait)
    if(monitoredProcess != null)
    monitoredProcess.destroy();
    //available for garbage collection
    // @PMD:REVIEWED:NullAssignment: by jbarde on 9/28/06 7:29 PM
    monitoredProcess = null;
    return;
    try
    sleep(1000);
    catch (InterruptedException e)
    if (ResourceString.getLocale() != null)
    Utility.log(Level.ERROR, ResourceString.getString("exception_in_sleep") + e.getLocalizedMessage());
    System.out.println(ResourceString.getString("exception_in_sleep") + e.getLocalizedMessage());
    else
    System.out.println("Exception in sleep" + e.getLocalizedMessage());
    if(monitoredProcess != null)
    monitoredProcess.destroy();
    //available for garbage collection
    // @PMD:REVIEWED:NullAssignment: by jbarde on 9/28/06 7:29 PM
    monitoredProcess = null;
    /*******************************supporting process controller class *********************************/

    Hi,
    Infact the command passed to the exec() is in the form of a batch file, which contains on of these commands. I can not put all commands in one batch file due to inherent nature of the program.
    But my main concern was that, why would it behave like this. If I run the same command for 30 times 1~3 times the same command can not be executed (returns with error code 1, on wiun2k pro) and rest times it works perfectly fine.
    Do you see any abnormality in the code.
    I ahve used the same sequence of code as in the article suggested by
    "masijade". i.e having threads to monitor the process and other threads to read and empty out the input and error streams so that the buffer does not get full.
    But I see here the problem is not of process getting hanged, I sense this because my waitFor() returns with error code as 1, had the process hanged it would not have returned , am I making sense?
    Regards,
    ~jaideep

  • Global vs interface switch command

    Hello, If I have a command globally which applies on all switch ports but then I want to configure one port with a different command not apply the global command on the switch. When i configure that port will it take effect the new command configure for that port and disregard the global command that was apply on the other ports?

    Well without testing and not knowing more details about what command you wish to try - I think that more specific (in this case interface command) will take precedence above global one...
    Plese do some testing - in this particular case it's about 5min job...
    BR,
    Dragan

Maybe you are looking for