Using Unix command lines in java code

I was wondering if there was a way to run a unix command in java code. I know in C++ there is popen, but i don't know of a way in java. The command i need to run is the whois "domain name" command. Any help would be great!
jarad

try something like this:
  public static String whois(String domain) throws IOException {
    BufferedReader is = null;
    Process p = null;
    String result = "";
    p = Runtime.getRuntime().exec("whois " + domain);
    is = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line;
    while((line = is.readLine()) != null)
      result += line;
    return result;
  }

Similar Messages

  • Using Unix Command Line to force logoff of other users

    Hello - I am the administrator for my family's Mac (OS X - 10.4.8). Four of us in the family share the system. Frequently, my family members forget to logoff. I would like to be able to force them off via the Unix command line. Can't I sign on as root and execute a "forced logoff" type of command?

    Thanks to Mihalis and Jarik for the additional info.
    I'm back now with a question. I have a user named "visitor" logged on. I issued a killall command which killed all the users processes except one. Using /Applications/Activity Monitor.app, I can see the process is "loginwindow" and it is owned by visitor.
    However,
    ps -u visitor
    reveals no running processes. Assuming I only had command-line access (no GUI to use Activity Monitor.app) and had multiple users logged in, how can I discover which loginwindow PID belongs to visitor?
    msq
    EDIT: I went ahead and sudo kill PID the loginwindow process owned by visitor and realized that
    ps -axj | grep visitor
    worked to reveal the loginwindow process owned by visitor. But when I logged visitor in (Fast User Switching) and ran sudo killall the Activity Monitor.app identifies the loginwindow as being owned by root but ps -axj | grep visitor shows the process belonging to visitor.
    Something weird in the depths of Leopard's UNIX land, but I think I can find my way around now.
    Thanks, everyone.
    Message was edited by: mistersquid

  • Help Please: How to invoke unix command lines from java?

    I have read past topics. Those are really helpful, but I still haven't got my job done. I tried the following:
    String command1 = "ls -la > ls1.txt";
    Runtime.getRuntime().exec(command1);
    String command2 = "tcsh -c ls -la > ls2.txt";
    Runtime.getRuntime().exec(command2);
    String command4 = "cp keywords.txt copyversion1.txt";
    Runtime.getRuntime().exec(command4);
    String command5 = "tcsh -c cp keywords.txt copyversion2.txt";
    Runtime.getRuntime().exec(command5);
    String command6 = "tcsh -c 'cp keywords.txt copyversion3.txt'";
    Runtime.getRuntime().exec(command6);
    Only "command4" works. Any input will be greatly appreciated.

    Thank you very much Gautam. Your solution certainly works. If you don't mind, I would like to ask you (or anybody who is willing to answer) something else. I am trying to run other types of unix command lines as well. I thought that the format you gave would work for everything. But it doesn't seem so:
    String command1[] = {"tcsh", "-c", "ls -la > ls1.txt "}; // this works as you suggested
    Runtime.getRuntime().exec(command1);
    String command12[] = {"tcsh", "-c", "lynx -dump http://www.yahoo.com > webpage.txt"}; //working fine.
    Runtime.getRuntime().exec(command12);
    String command10[] = {"tcsh", "-c", "ngram-count -text keywords.txt -lm LM10 &"}; //doesn't work
    Runtime.getRuntime().exec(command10);
    String command[] = {"tcsh", "-c", "/u/drspeech/sun4/bin/ngram-count -text keywords.txt -lm LM0 &"}; // doesn't work
    Runtime.getRuntime().exec(command);
    String command13[] = {"tcsh", "-c", "ngc -text keywords.txt -lm LM13"}; // doesn't work
    Runtime.getRuntime().exec(command13);
    String command8 = "ngram-count -text keywords.txt -lm LM8 &"; //doesn't work
    Runtime.getRuntime().exec(command8);
    String command9 = "/u/drspeech/sun4/bin/ngram-count -text keywords.txt -lm LM9 &"; //doesn't work
    Runtime.getRuntime().exec(command9);
    I tried "commandd1" and "command12". Those worked fine. No problemo. However, there's someting else I need to get done for my job; that is "command10". But it just didn't work. I thought maybe, it's because "ngram-count" is not part of the standard UNIX commands. So, I thought I might just add another alias for it in the ".cshrc" file and call it "ngc" instead. Then I tried to call the alias "ngc" instead. But it didn't work also. Then I thought, maybe, I should call it by referencing it from its original directory "/u/drspeech/sun4/bin/ngram-count". That didn't work either. I tried a couple of other combinations. None worked. I would really like to see how to solve this.

  • Compressing a large PDF document using command line or Java code without GUI operations

    hi,
    I have a programatically generated very large PDF file with lots of tables and cells in it. The size of the file is few MBs. Using Adobe pro, I am able to reduce the size of the PDF in KBs. I want to achive it either through a command line or using Java API without GUI interaction.
    I am using JDK1.6.
    Thanks.

    I think you need the scripting or SDK forums http://forums.adobe.com/community/acrobat
    As far as I know, Acrobat does not have command line operation

  • Can I use the Command Line Interface on Unix?

    Hi,
    We use 9iAS on Unix. We want to use Discoverer Command Line Interface on unix to export the worksheet query result. Can anyone know how to do this? I couldn't find out the command similar to dis5usr.exe for windows version.
    Thanks.
    Richard Qiu

    Hello Richard
    You can use the Discoverer EUL Command Line for Java utility. This was released with Discoverer 10g (9.0.4).
    Please refer to the documentation for more information on how to use this command line interface: 'Oracle Discoverer EUL Command Line for Java User's Guide 10g (9.0.4), Part No. B10274_01 (PDF)' The document is available from OTN at http://otn.oracle.com/documentation/discoverer.html
    Regards
    Discoverer Product Management

  • Java , abab stack restart by using unix commands

    hi experts,
    i need steps to restart java , abab stack restart by using unix commands.
    plz any one give me clear steps.
    thanks& regards,
    Xi reddy

    Hi,
    Check following
    http://help.sap.com/saphelp_nw04/helpdata/en/5d/c4dd9b9d91dd458e9e5c0386edeb86/frameset.htm
    http://help.sap.com/saphelp_nw04s/helpdata/en/fe/40a04270600d31e10000000a1550b0/frameset.htm
    http://help.sap.com/saphelp_nw04s/helpdata/en/85/24a64201e7c511e10000000a1550b0/frameset.htm
    regards,
    kaushal

  • Unable to run reports from the unix command line

    hi
    all of a sudden i am unable to run reports ( on App server 10g) either from the unix scripts or from the unix command line. But i can run them from the forms.
    Any one have any idead about this.
    Thank you

    thanks all for replying
    i have set the env variables for the session and it worked. Looks like i have to set the oracle_home and ld_library_path every time ( opening a new putty session) i call sqlldr.
    But in a whole i am trying to run sql loader from the forms. Right now we have Oracle app server 10g which forms 10g version. As oracle app server 10g didnt come with sqlldr, we are copied the sqlldr of database on to app server with different home. after this we can run sqlldr ( on app server ) from unix scripts but not from Forms. Then we opened a qurey with oracle about app server 10g not commig with sqlldr and its remedy . But they said that they dont have specific remedy for that and suggested the same what we did.
    So we came up with java package which does the same funtion as host command and trying to run sqlldr which is on the database( ie replacing the host command in the forms with the database funtion). By using that funtion i am able to run the sqlldr from sql plus but not from forms. I couldnt easily debug it as i wont through any error messages.
    Any one have any idea of this ...
    Thank you

  • How can I import eex files into Applications EUL from the unix command line

    How can I import *.eex and *.dis files into an Applications EUL from the unix command line?
    Thanks

    Hi
    The simple answer is you either have to use the client tool DIS51ADM to import files using the command line (Discoverer Admin is a windows only client tool), or the Java command line which needs a browser.
    In theory if you have a browser running on your Unix box you may be able to use the Java command line to make this work.
    Best wishes
    Michael

  • How can I use unix commands from oracle report

    I have to use the following command from oracle reports.
    In oracle forms we can use the HOST command but what about oracle reports2.5.
    I have to email the attached file 100245.pdf from oracle reports to the given email id
    uuencode 100245.pdf 100245.pdf | mailx -s "test" [email protected]

    Hi,
    It's because .bat (or .cmd) files are scripts and not executables and are interpreted using the command line executable - which is normally cmd.exe (although you can buy others).
    So you need to call cmd.exe passing the bat file name as a parameter, something like
    cmd.exe /c batchfilename
    Without the /c you will never get a response.
    However, this brings us to the bizarre conclusion that you are going to:
    call cmd.exe (a shell interpreter)
    to launch a batch file
    that calls cygwin (another shell interpreter)
    which then runs ls
    When shouldn't that just be:
    call cmd.exe to run the dir command
    Or better yet, If you are just after a file name listing and you seem to understand Java stored procs, why not just write a JSP to list the contents of a directory? No problems with OS dependant commands, scripts and 3rd party interpreters. Plenty of examples of that out on the internet as well.
    HTH
    Chris

  • Issue while creating BPEL artifacts using BPEL command line tool

    All
    I am trying to create BPEL artificats for SQL server stored procedure for SQO Server 2005 using BPEL Command line tool.
    My demo.properties is
    ProductName=Microsoft SQL Server
    DriverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
    ConnectionString=jdbc:sqlserver://10.10.20.2:1433;databaseName=dAP
    Username:apcdb
    Password:password1
    SchemaName:dev
    ProcedureName:spiSOATesting
    ServiceName:SQLServerSPService
    DatabaseConnection:MSSQLServer
    Destination:c:/temp/sqlprocedure
    and I have create a batch file called as generate.bat and it contains following information
    java -cp D:\jdevstudio10134\integration\lib\DBAdapter.jar;D:\jdevstudio10134\integration\lib\bpm-infra.jar;D:\jdevstudio10134\integration\lib\orabpel.jar;D:\jdevstudio10134\lib\xmlparserv2.jar;D:\jdevstudio10134\lib\xschema.jar;D:\jdevstudio10134\toplink\jlib\toplink.jar;D:\jdevstudio10134\integration\lib\connector15.jar;D:\temp\sqlprocedure\JDBC\sqljdbc.jar oracle.tip.adapter.db.sp.artifacts.GenerateArtifacts %1
    and when I try to run the command at BPEL PM Developer Prompt, I am getting Procedure not found, Can one please tell, what is the cause of this error. and how does this command line tool exactly work.
    Following is the output from command prompt.
    D:\product\10.1.3.1\OracleAS_1\bpel\samples>D:\temp\sqlprocedure\generate.bat D:\temp\sqlprocedure\demo.properties
    D:\product\10.1.3.1\OracleAS_1\bpel\samples>java -cp D:\jdevstudio10134\integration\lib\DBAdapter.jar;D:\jdevstudio10134\integration\lib\bpm-infra.jar
    ;D:\jdevstudio10134\integration\lib\orabpel.jar;D:\jdevstudio10134\lib\xmlparserv2.jar;D:\jdevstudio10134\lib\xschema.jar;D:\jdevstudio10134\toplink\j
    lib\toplink.jar;D:\jdevstudio10134\integration\lib\connector15.jar;D:\temp\sqlprocedure\JDBC\sqljdbc.jar oracle.tip.adapter.db.sp.artifacts.GenerateArtifacts D:\temp\sqlprocedure\demo.properties
    Procedure not found: dAP.spiSOATesting
    Thank you

    HI
      Pricing will be carried basing on the pricing
    procedure.
    Case1: Prices will be carried out automatically if
    necessary condition records are maintained for the
    condition type.
      For this you can go to Sales Order-> Item Conditions
    In the screen you can click on command button Analysis,
    which gives you the list of condition types associated
    to the pricing procedure. By clicking on the condition
    type you can know the action that has taken place.
    Case2: Manually forcing prices for Items.
      To do this, you have to populate ORDER_CONDITIONS_IN &
    ORDER_CONDITIONS_INX. Also note to identify the item
    numbers, you manually pass the item number for each item
    in the sales order, use the same item number for
    populating conditions.
      Parameters required:
    ORDER_CONDITIONS_IN:
      ITM_NUMBER, COND_TYPE, COND_VALUE, CURRENCY
    ORDER_CONDITIONS_INX:
      ITM_NUMBER, COND_TYPE, UPDATEFLAG, COND_VALUE,CURRENCY.
       Hope the above info helps you. Do revert back if you
    need more info.
    Kind Regards
    Eswar

  • Using the command line client...

    I've got a few thousand videos, with metadata, that I have to add to an existing FCS install. Right now, I'm just trying to figure out the proper way to use the command line.
    If I run the following command as root (paasset_predict_motorvideo is the name of my metadata set, as listed in the admin app...)
    bash-3.2# ./fcsvr_client createasset paasset_predict_motorvideo /Users/bfinley/Desktop/test.mov
    I get the following error:
    { CODE = E_NOTSUPP, DESC = Entity /Users/bfinley/Desktop/test.mov doesn't know how to do anything, SRC_FILE = PmdEntity.C, SRC_LINE = 1509, ERROR_TYPE = ET_PERM, ADDRESS = /Users/bfinley/Desktop/test.mov }
    If I pass in the --host, --user, and -pass on the same command, i get:
    { CODE = EMISSINGPARAM, DESC = CURRENTPERMID missing in PmsTask_QueryPerms, looks like unknown node failed to pass it down to child unknown node, NODE = ["PmsTask_QueryPerms" 0x2a51c50, ref=3, wref=2] taskState=0 dbqueue=0x184fb64 needTrans, SRC_FILE = PmsTask_QueryPerms.C, SRC_LINE = 136 }
    I don't need to add any metadata to it, and i get the same error whether I enter any metadata at the end of the query or not.
    I just have a pile of videos, the filenames of which are keys to a table that contains the rest of the metadata, and I want to automate the addition of them to the new FC Server install.
    Am I going about this the wrong way?
    Thanks in advance.

    Brian:
    I've start by placing assets into a device that is configured with Final Cut Server (FCSvr).
    Example, let say you have a folder on your desktop name 1000videos.
    Create a device in FCSvr and map it to /Users/bfinley/1000videos.
    Name this Device with the name of your choice i.e. Library2
    Don't apply any scan schedules to this device etc.
    After you're done with that determine the device id of the new created device by running this command
    ./fcsvr_client search /dev
    you get some output like
    Address DEVICE_NAME DEVICE_TYPE
    /dev/7 Archive_Device filesystem
    /dev/13 Library filesystem
    /dev/10 Media filesystem
    Note down the device id of your newly created device i.e. /dev/13
    Next assuming that you have a file with a filename of test.mov
    use the following command
    sudo fcsvr_client createasset paasset_predict_motorvideo /dev13/test.mov
    you should receive a response to this output containing the newly create asset id.
    Hope this helps.
    Nicholas Stokes
    XPlatform Consulting
    [email protected]

  • How to make system call to execute command line in JAVA?

    Hi,
    I am new in JAVA. How to make system call to execute the following command line in JAVA in LINUX environment.
    rpm -qa jdkIn C programming, use as such:
    system ("rpm -qa jdk");
    How about JAVA?
    Thanks.

    Runtime.getRuntime().exec. But first read this:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • How to run Discoverer 10g report from unix command line

    Hello Experts,
    I am aware that discoverer report can run through command line using "dis51usr.exe /connect username/passward@connection_string /opendb "DISCOVERER.<<report name>> /export xls"".
    Can we run discoverer 10g report (stored in database) from server location / unix command line? Is there any command?
    Please assist. Thank you.

    Hi Tamir,
    Can you please mention from where we have to execute/run these commands? After setting enviornmental variable, are these commands run from any location or we have to go to particular server location and then execute (ex. from directory BI or else).
    Thank you.

  • Installing a New Windows Server 2008 R2 Child Domain by Using the Command Line

    Installing a New Windows Server 2008 R2 Child Domain by Using the Command Line:
    http://technet.microsoft.com/en-us/library/cc731873%28v=ws.10%29.aspx
    dcpromo /unattend /InstallDns:yes /ParentDomainDNSName:mysite.com /replicaOrNewDomain:domain /newDomain:child /newDomainDnsName:gridview.mysite.com /childName:gridview /DomainNetbiosName:gridview
    /databasePath:"c:\Windows\ntds" /logPath:"c:\Windows\ntds" /sysvolpath:"c:\Windows\SYSVOL" /safeModeAdminPassword:pass1 /forestLevel:4 /domainLevel:4 /rebootOnCompletion:yes
    Error Code:
    The specific argument 'childName' is not recognized.
    I am trying to insert gridview as a childname.

    Hi,
    Before going further, can we try another domain name to see what will happen?
    Besides, if the issue persists, we can try installing a new child domain by using the GUI.
    Installing a New Child Domain by Using the Graphical User Interface (GUI)
    http://technet.microsoft.com/en-us/library/cc771856(v=ws.10).aspx
    Best regards,
    Frank Shen

  • Using Unix commands

    Im creating a webserver in java and I want to use UNIX commands to access another directory and run a CGI script. Im trying to cd into the cgi-bin directory and run the script using the Process and Runtime classes but it doesn't seem to change to the cgi-bin directory. Is there another way I'm supposed to do this in java?

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

Maybe you are looking for

  • How do I see which calendar invitations have been accepted?

    Hi There. I have received confirmation that calendar invitiations have been accepted. There is a number next to the applicable calendar i.e. work (2), showing the number of acceptances, however as I send out multiple invitations to separate events I'

  • When i set a event on my mac it shows a different time on my iphone

    what is the solution, event time set on my imac, say 8am shows on my iphone cal as 4pm?

  • Why can't I move my songs move into a playlist any more?

    I have discovered recently that the songs in my music library, both old and new, will not move as they always did, by clicking and dragging into a playlist.  I get a red crossed out circle and they just won't move!  Help!

  • Signing in to Premiere after reloading.

    I had to reload Premiere after a lightning strike took out my computer. On the new computer, I get a sign in message which tells me I can't sign in because I am offline or the computer clock is set incorrectly. Neither is the case. How do I get out o

  • Worried about CPU temp

    I've been having graphic issues with my MSI Gf4 and MSI KT4VL, and its come to my attention that my CPU temp is 72. I know thats way too high and could possibly be a cause of my problem. What should i get to cool down my CPU, bearing in mind its an A