Running command from command prompt

hai all,
iam using Javamail to send emails. for that iam using the command prompt.the code for executing the commands from the command prompt is as given below.
public static String runCommand(String s)
String result=new String();
     try
     //the command is executed and stored in 'p'
     Process p=Runtime.getRuntime().exe("cmd /c "+s);
     result=(loadStream(p.getInputStream()));
     if(p.waitFor()!=0)
     System.out.println("Exit Value = "+p.exitValue());
     System.out.println("Wait for = "+p.waitFor());
System.out.println("Result is "+result);
     catch(IOException e)
System.out.println("IO Exception");
     e.printStackTrace();
     catch(InterruptedException e)
System.err.println("Interrupted waiting for process!");
     return result;
the contents of the 'javamail' directory are
activation.jar, mail.jar, Msgmultisendsample.java and Msgmultisendsample.class
in the first call to this method i pass the string "set classpath=%classpath%;e:\javamail\mail.jar;e:\javamail\activation.jar;e:\javamail; " here i set the classpath since i will be executing the command from the command prompt.the command works fine and the exitValue() is 0.
in the second call to this method i pass the string "java Msgmultisendsample [email protected] abc 123.456.789.012 true" for running the Msgmultisendsample.class file. but i get the exitValue() as 1 and the command is not getting executed. i dont know how handle this change in the exitValue().
both the above commands works fine if i run directly from C:\ but not when called to this method.
Please help me out people, i will be glad to receieve the replies as early as possible since i have to submit this tomorrow.
Thanks in advance,
Jayanth.

well, the problem is not with the command line arguments. it doesnt matter if we get the input from the user through command prompt or GUI. The problem is only in the handling of the change in exitValue during running.

Similar Messages

  • Running command prompt externally from Java

    Hi,
    Does anyone know how to make a Java program that opens up the command prompt and runs certain commands? Thanks,
    Adam

    Read this before you use it:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Running command prompt using java

    hi guys,
    i am still quite new to programming. may i know how to run a bat file or command in the background of the application
    without showing the command prompt.
    right now i am able to do it, however it will still pop up the command prompt
    the following is my coding.
    try {
                String command = "cmd /C start C:/project/mkiosk/lib/createMovieJar.bat ";
                Runtime rt = Runtime.getRuntime();
                pr = rt.exec(command);
            } catch (IOException e) {
                e.printStackTrace();
            }

    xclaim wrote:
    ...the following is my coding.
    try {
    Runtime rt = Runtime.getRuntime();
    pr = rt.exec(command);
    ProcessBuilder is a more robust way of creating a Process.
    To avoid problems later, read and implement all the recommendations of [When Runtime.exec() won't|http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html] *(<- link).*
    And as an aside, please put a single upper case letter at the start of every sentence. Adding the capital letter helps people to quickly scan the text, looking for ways to help. You would not want to make it harder to help, would you?

  • Running command prompt commands in java

    I can use:
    Process j = Runtime.getRuntime().exec("command";
    BufferedReader stdInput = new BufferedReader(new InputStreamReader(j.getInputStream()));
    BufferedReader stdError = new BufferedReader(new InputStreamReader(j.getErrorStream()));
    to run commands in the command line buf if i make another process..the command will not run...any ideas?

    ProcessBuilder can simplify things:
    redirectErrorStream
    <quote>
    If this property is true, then any error output generated by subprocesses subsequently started by this object's start() method will be merged with the standard output, so that both can be read using the Process.getInputStream() method. This makes it easier to correlate error messages with the corresponding output.
    </quote>

  • Running odihragent from shell prompt

    Hi
    I am currently trying to run odihragent from a shell prompt to do some debugging however I am not sure of the date format that it expects? Can anybody help?
    /oracle/10gASR2/ldap/odi/bin/odihragent OracleHRAgent connect=find login=apps pass=*** date=200501011200
    status= -1
    Error - ORA-01722: invalid number
    Error in OCIStmtExecute
    Error in Execute
    HR Agent failed with Status:2

    well, the problem is not with the command line arguments. it doesnt matter if we get the input from the user through command prompt or GUI. The problem is only in the handling of the change in exitValue during running.

  • When you run windows 7 using bootcamp, are you able to run Command Prompt as you would on a regular pc?

    Because I want to be able to do things like Visual Basic and run programs,codes,etc. I just don't want to get a PC. I'm studying Computer Science and I know most of the things I will be dealing with will mainly be with Windows OS is why I'm asking.
    Thanks in advance

    Running Windows in a Boot Camp partition is the same as running Windows on a Windows PC.

  • Run report from Unix prompt

    Hi,
    for audit reasons we need to run a report again. Therefore a changed the where-clause of the report. Since the report needs to run on our production system and the prodcution-version of the report can not be changed, I need to run the report from the unix prompt. Can anyone tell me how to run an Oracle reports 2.5 from the uni prompt. We are using Oracle Applications and therefor still on reports 2.5....
    I tried to run the report from the client, but since the report fetches alot of data, my harddrive with 1.7GB of free space ran out of resources. Therefore I can only run the report on the production system (a little bit more resources...).
    Thanks in advance, Roel.

    Hi Roel,
    Go to $ORACLE_HOME/bin directory. You can see the reports executables r25runm - Runtime, r25clim - Client.
    You can run your report like this:
    r25runm report=myreport.rdf userid=scott/tiger@mydb destype=file desformat=pdf desname=myreport.pdf
    (or)
    r25clim report=myreport.rdf userid=scott/tiger@mydb destype=file desformat=pdf desname=myreport.pdf server=myserver
    Please, Change the desformat and destype as per your requirement.
    -Siva B

  • How to run clientgen from Workshop 9.2 IDE

    Is there a way to run clientgen for wsdl from within IDE, rather than creating your ant script and running it from dos prompt.
    -Anil Patel

    Hi Andrey,
    Are you on Workshop 9.2.1 ?
    The client jar gets created only during publish. Hence if you have deployed your application or ejb to a running server instance and you choose to publish the app, the jar will be created in the root of your project, assuming you have left default values.
    You can run a quick test by right clicking the project and selecting WebLogic EJB
    In that screen uncheck use default setting for the client jar value and specify your own jar file name
    with the server running, publish the app to the server.
    the jar should be created in the root of your project.
    you can always specify the fullpath to the jar too
    let me know if this works for you
    cheers
    Raj

  • Unable to run discoverer report from command prompt

    Hi,
    I'm trying to run the discoverer report from command prompt and i need to schedule the same.
    How could i pass multiple values for the parameters?
    If i don't pass the optional parameters, the parameter screen is getting pop-up? How to skip optional parameters?
    Also, how to pass the data ranges (format for date parameters) ?
    I'm using the below command in command prompt:
    cd/d E:\oracle\BIToolsHome_1\bin
    dis51usr /connect username/password@database /opendb "TIMS-PCJ status Report" /sheet "TIMS observation status report (based on performed date)" /parameter "Test Number" 40351 /parameter "From Date" "01-JAN-2007" /parameter "To Date" "28-FEB-2007" /parameter "Observation Status" C /parameter "Observation Name" "Abdominal Girth" /export HTML "C:\DISCOVERER_REPORT_SCHEDULING\DIS_OUTPUT\PCJStatusOutput11"
    Any one please reply me. Its very urgent.
    Regards,
    Sreedhar

    Hi,
    How could i pass multiple values for the parameters? You should be able to use a comma separated list e.g.
    /parameter "Observation Name" "'Abdominal Girth','Abdominal Girth2'"
    How to skip optional parameters?I don't think you can. You have to supply all parameters and then decode out the parameters you don't need in the workbook.
    how to pass the data ranges You cannot pass a date range. You can pass a start and end parameters. The default format for the date parameters is DD-MON-YYYY but this can change depending on the NLS settings and format of the data item.
    Rod West

  • How to run a program as an administrator from within a non-elevated command prompt?

    I have a project that is going to be running on a kiosk, and the user that is running the kiosk software is going to be restricted.  I have an alternate administrator account, but I cannot seem to figure out how to open my program running as this administrator
    user.  I have tried to use runas, like so:
    runas /user:admin kiosk.exe
    However, when I try to run this command, it asks me for the password of the administrator account and my program doesn't open correctly.  It fails to open at all.  If I change the run as to a start command, then the program executes fine so its
    not a problem with my software.
    Is there a way to pass a password parameter to runas so that it will not prompt for the password every time?  If there is not, can someone think of another way for me to elevate my process to administrator without being logged in as one through the
    command prompt?

    Hi KevinGEAR,
    You want to allow the others without the administrator`s level to run this software and  meanwhile the administrator is not logged in, right?
    Here is an alternative solution :
    1.To work with this solution, a built-in administrator account should be enabled and meanwhile you can create a standard account. The built-in administrator account is different from the administrator account you created.
    To enable built-in administrator account:
    Ways to Enable / Disable the Built-In Windows 7 Admin Account
    http://social.technet.microsoft.com/wiki/contents/articles/3040.enable-disable-the-local-hidden-built-in-administrator-account-in-windows-7.aspx
    2. Use the following code
    runas /user:ComputerName\Administrator /savecred "Full path to program's exe file"
    Here is a link for reference:
    Elevated Program Shortcut - Create for Standard User
    http://www.sevenforums.com/tutorials/193743-elevated-program-shortcut-create-standard-user.html
    NOTE: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites.
    Best Regards

  • Error when running a scenario from Command Prompt

    Hi I edited the parameter file and I am trying to run an interface that joins two tables from HR schema and loads into a table in different schema. I am able to run this in the Designer, but I receive an error message when I try to run it through command prompt.
    Here is the error message I get when I try to run it
    09/09/2009 11:58:42 AM(main): Creating session for scenario:DEMO_INTERFACE - 001
    09/09/2009 11:58:42 AM(main): Session : 88010 is running
    com.sunopsis.core.SnpsInexistantObjectException: There is no connection for this
    logical schema/context pair:HR / GLOBAL
    at com.sunopsis.dwg.dbobj.SnpConnect.getSnpConnectByLSchemaNameAndContex
    t(SnpConnect.java)
    at com.sunopsis.dwg.dbobj.SnpConnect.getSnpConnect(SnpConnect.java)
    at com.sunopsis.dwg.dbobj.SnpSession.getDwgConnectLst(SnpSession.java)
    at com.sunopsis.dwg.dbobj.SnpSession.getConLst(SnpSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandScenario.treatCommand(DwgCommandScenar
    io.java)
    at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
    at com.sunopsis.dwg.cmd.e.i(e.java)
    at com.sunopsis.dwg.cmd.e.y(e.java)
    at com.sunopsis.dwg.DwgJv.treatCmd(DwgJv.java)
    at com.sunopsis.dwg.DwgJv.main(DwgJv.java)
    at oracle.odi.Agent.main(Agent.java)
    09/09/2009 11:58:43 AM(main): Session : 88010 finished with return code : -1
    com.sunopsis.core.SnpsInexistantObjectException: There is no connection for this
    logical schema/context pair:HR / GLOBAL
    at com.sunopsis.dwg.dbobj.SnpConnect.getSnpConnectByLSchemaNameAndContexur
    t(SnpConnect.java)
    at com.sunopsis.dwg.dbobj.SnpConnect.getSnpConnect(SnpConnect.java)
    at com.sunopsis.dwg.dbobj.SnpSession.getDwgConnectLst(SnpSession.java)
    at com.sunopsis.dwg.dbobj.SnpSession.getConLst(SnpSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandScenario.treatCommand(DwgCommandScenar
    io.java)
    at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
    at com.sunopsis.dwg.cmd.e.i(e.java)
    at com.sunopsis.dwg.cmd.e.y(e.java)
    at com.sunopsis.dwg.DwgJv.treatCmd(DwgJv.java)
    at com.sunopsis.dwg.DwgJv.main(DwgJv.java)
    at oracle.odi.Agent.main(Agent.java)
    DwgJv.main: Exit. Return code:-1
    Thank you for your help.
    Kranthi

    Hello,
    Try to remove and recreate your package and scenario, I had the same issue and solved doing it.
    It seems for me that the package cannot update its contents, for example, if you change something in your interface, you must recreate your package and scenario to update the changes.
    What ODI version do you use? If you use an old version, try to update to ODI 10.1.3.5
    Regards,
    Wallace Galvão
    São Paulo - Brazil

  • Error while running a ODI scenario from command prompt

    Hi,
    I'm trying to run a ODI scenario from command prompt. I've edited the tnsnames.ora and odiparam.bat file with exact host and port details. Even though I'm facing the below error.
    command:startcmd.bat OdiStartScen -SCEN_NAME=INT.CUSTOMER_STG -SCEN_VERSION=001 -CONTEXT=ICM -AGENT_CODE=KANBAN
    Error: java.sql.SQLException: Listener refused the connection with the following error:
    ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
    The Connection descriptor used by the client was:
    localhost:1521:orcl
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:280)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:328)
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:361)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:151)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:595)
    at com.sunopsis.sql.SnpsConnection.u(SnpsConnection.java)
    at com.sunopsis.sql.SnpsConnection.c(SnpsConnection.java)
    at com.sunopsis.sql.i.run(i.java)
    Please help in resolving the error...
    Thanks in advance.
    Edited by: 894841 on Dec 22, 2011 11:15 PM

    Hi,
    Are you able to start the Standalone Agent(KANBAN) and test it in the Topology?
    Check the value of the ODI_MASTER_URL variable in odiparams file(at the path <ODI_HOME>\oracledi\agent\bin) of the agent.
    Specify the full the JDBC URL properly not like localhost(until the DB is on same machine as your ODI).

  • Cant run a program from command prompt

    i am using eclipse 3.2 for java development.
    programs are running from editor window, but whenever i am trying to run it from command prmpt , i am getting folowing error...
    ..........NoClassDefinitionFound
    how to resolve it...??
    regards
    yogesh g k

    Since there have been a lot of posts from people who fail to compile and run their correct code, I would like to suggest to use ant for building and running! It hides the complexities of specifying the correct paths and a lot it's easier to type
    prompt>ant
    at the command line than
    prompt>javac -d . -cp .;longListOfJarsNeededToRun somePackage/*.java aLotOfOtherFilesToCompile.java
    prompt>java -cp .;longListOfJarsNeededToRun somePackage.someClass
    It takes some time to get familiar with the configuration, but once you get it right, you gain back a lot of your invested time!

  • Encountering a RunTime error when I try running from command prompt

    When I try to load my class from the command prompt I get the error:
    Exception in thread "main" java.lang.NoClassDefFoundError: MiniTriangle
    Since this seems like a pretty basic error, I'm hoping there's a black and white solution to it. Unfortunatly I don't have the slightest idea what that might be.
    Any help would be appreciated, thanks in advance!!!

    I'm pretty new to this myself but have encountered this error before. I've found it happens when you try to run the programme and the class name isn't the same as the file name. So if you named the text file when you wrote the code MiniTriangle when you compile it you will get a file called MiniTriangle.class which is what you are trying to run. However if you inadvertently misspelled the class definition in the code and entered say
    class MiniTringle {
    you would get the error you are experiencing when you try to run MiniTriangle.class
    Hope this helps

  • Running SQLPLUS script from command prompt on SUN

    We are making a migration from VMS to SUN ( SunOS 5.10) and from 9i to 10g. We have encountered an unanticipated problem with running scripts from the command line in SUN(SQLPLUS execution from the command line). All of our packages have a naming convention such as "DM$LOAD.PKB". I know it is a strange naming convention.
    The problem is that when the package creation script is run in SQLPLUS at the command prompt SQLPLUS can not open the file.
    SQL> @dm$load.pb
    SP2-0310: unable to open file "dm$load.pb"
    SQL> host ls
    dm$load.pkb
    SQL>
    Setting the escape character does not seem to help.
    SQL> set escape '\'
    SQL>
    SQL> @dm\$load.pb
    SP2-0310: unable to open file "dm$load.pb"
    SQL>
    Unfortunately, we can not rename the scripts. This can be done from a shell script, but our Tech Services refuse to run the SQL scripts from a shell script
    Any ideas on how to get SQLPLUS to run the scripts from the SUN command line?

    I did not notice that the cut and paste was poor. It should have read
    SQL> @dm$load.pkb
    SP2-0310: unable to open file "dm$load.pkb"
    SQL> host ls
    dm$load.pkb
    Any ideas will be greatly appreciated.

  • VBScript Runs Correctly From Command Prompt, But Not From SQL Server Agent Job

    I'm trying to run this script on my local machine to do some post-batch cleanup and it doesn't run correctly from the scheduled job (or when I invoke the job).
    Here's the script in question:
    Option Explicit
    Const filePath = "C:\Documents and Settings\jmunn\My Documents\Visual Studio 2008\Logs\"
    Const holdDays = 6
    main
    Sub Main()
    ClearArchive
    End Sub
    Sub ClearArchive()
    Dim fso 'As Scripting.FileSystemObject
    Dim fld 'As Scripting.Folder
    Dim f 'As Scripting.File
    Dim delLogName, delLogOut, delCtr
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set fld = fso.GetFolder(filePath)
    delLogName = filePath & "Nightly Backup - Backup Logs Deleted" & ".txt"
    Set delLogOut = fso.CreateTextFile(delLogName, True)
    delLogOut.WriteLine(delLogName)
    delLogOut.WriteLine("")
    delLogOut.WriteLine("-- The following log files were deleted on " & DateValue(Now()) & " at " & TimeValue(Now()))
    delLogOut.WriteLine("")
    delCtr = 0
    For Each f In fld.Files
    If Left(f.Name, 48) = "Nightly Backup - SQL Server Databases_Subplan_1_" And Right(LCase(f.Name), 4) = ".txt" Then
    If DateDiff("d", f.DateCreated, Date()) > holdDays Then
    delLogOut.WriteLine(f.Name)
    fso.DeleteFile f, True
    delCtr = delCtr + 1
    End If
    End If
    Next
    If delCtr = 0 Then
    delLogOut.WriteLine("No log files were deleted this run...")
    End If
    Set fld = Nothing
    Set fso = Nothing
    delLogOut.Close
    End Sub
    If I put the script in its own file and run it from the command prompt, it runs just fine. If the script runs from the SQL Server Agent job, the for-loop will delete the files correctly, but the filenames
    do not get written to the deletion log file and the counter does not get incremented, so according to the job log, nothing was deleted. Why does the script run differently from each invocation? It can't be a permission thing, the service that logs in has full
    access to the directory and the files do get deleted. Any ideas out there?
    Between this and other outstanding issues, I'm quickly losing faith in SQL Server.  >=o(
    Thanks in advance for your thoughts!
    John
    Version Info:
    Microsoft SQL Server Management Studio      10.0.2531.0
    Microsoft Analysis Services Client Tools      10.0.1600.22
    Microsoft Data Access Components (MDAC)      3.85.1132
    Microsoft MSXML      2.6 3.0 4.0 5.0 6.0
    Microsoft Internet Explorer      8.0.6001.18702
    Microsoft .NET Framework      2.0.50727.3603
    Operating System      5.1.2600
    "A bus station is where a bus stops. A train station is where a train stops. On my desk I have a workstation..."

    Hi
    jrmunn
    i am trying to execute VB script to refresh my excel files.. using Vbscript file through SQL Agent job step.
    i have copied VBscript in a file with the extension RefreshExcel.vbs kept in C:\RefreshExcel.vbs
    Below is the script used inside the file (RefreshExcel.vbs)
    //---Script code-----------------------------------------------------------------
    Dim objXL, objWB
    Dim FileLocation, FileName
    On Error Resume Next
    'lgnConn = 1
    FileLocation = "F:\Reports\Reports"
    Set objXL = CreateObject("Excel.Application")
    objXL.DisplayAlerts = False
    FileName = "ReportFile1.xlsx"
    'MsgBox (FileLocation & "/" & FileName)
    Set objWB = objXL.Workbooks.Open(FileLocation & "/" & FileName)
    objWB.EnableConnections
    objXL.CalculateUntilAsyncQueriesDone
    objWB.RefreshAll
    objXL.CalculateUntilAsyncQueriesDone
    objWB.RefreshAll
    objXL.CalculateUntilAsyncQueriesDone
    objWB.Save
    objWB.Close
    Set objWS = Nothing
    Set objWB = Nothing
    objXL.Quit
    Set objXL = Nothing
    'MsgBox ("Refresh Completed")
    ---------------------------------------------------------------------------------------------------//Script complete
    Now when i am trying to call this script file in SQL agent job step (as you mentioned )
    as Type -cmdExec(OperatingSystem)
    cscript "C:\RefreshExcel.vbs"
    Issue: job step executed succesfully ,,but without performing any refresh on the excel. So i am not understandig what is going wrong. the same script file work when i am calling it through a batch file (window scheuler task). But it doesnt support
    to run the file "when user is not logged in"
    that is why  i want to refresh my excel file through sql agent ,which can be scheduled to any time and cab be run as SQL agent credentials.
    Can you please help me on this ...i have tried all the option but nothing working .. found hope by seeing your solution.
    Thanks in advance.
    Please help me. :-(

Maybe you are looking for

  • EntityBeans does not show row update.

    Hello, I make an EntityBean I make a EntityFacade SessionBean for it. I make a servlet that through EntityFacade call the findAll() method.. When I run the servlet, it show the row contained in the EntityBean correspondent Database Table. When I add

  • Prob in activating a field in delivery while creating delivery via VL04

    hi thx i am also facing the same prob. this badi is working while creating deliveries via VL01N OR VL02N but if we are creating delivery via VL04 this badi is not working, can u please guide me. thanx in adv.

  • How to find files on Iphone?

    How do I see all the files on my iphone? I'm looking for a jpg image taken with my iphone using the "night photo" app, and I can't find it. I tried to search using SPOTLIGHT on my macbook and there does not seem to be any way to have it search my Iph

  • Exporting to Dedicated Encoder

    I am researching the possibility of changing my groups editing workflow. Right now we are doing almost all of our editing on one machine. As more projects come in we are having trouble with only having the one high end machine. The other issue is tha

  • File to table

    I run a Web-based application and using a PLSql procedure in a package I want to get the contents of a flat file that is in a directory on the server into a table in the database. What functions/procedures can I use to achieve this?