How to output instructions to the command line?

How can I make my java program give instructions to the command line, eg to execute programs with command line parameters?

How can I make my java program give instructions to the command line, eg to execute programs with command line parameters? well you can execute the instruction directly not even going(piping through) to commandline.
try{
String command = "ls"; // for windows for example String command = "notepad";
Process execCommand = Runtime.getRuntime().exec(command);
// now if you want to pass parameters along with the  command use this
String command2 ="ls /tmp" ; //respectively for windows
// if there are many arguments which needs spaces then use
String [] longCommand = new String[]{"find","whatever","path"}; // here find is the command and rest two are desired arguments.
// now if you want to read the output from command line
InputStream in = execCommand.getInputStream();
int c;
while ((c=in.read())!= -1)
// process c the way you want
} catch(IOException io)
{}Edited by: KillerDev on Nov 2, 2008 12:00 AM

Similar Messages

  • Dumb question- how do I get to the command line without X running?

    Hi,
    As per the title please... I need to rerun Xorg -configure, but cannot for the life of me figure out how to shut down X and get to a command line
    Thanks

    Bes wrote:
    Ctl alt and backspace just takes me out to the login screen.. from there I can't get to the terminal without X running.
    Ctrl Alt F5 gets me to the command line, but I can't kill the X server
    Thanks though
    so with ctrl+alt+f5 you're at the console
    log in if you need to, then
    ps ax | grep gdm
    4441 ? Ss 0:00 /usr/sbin/gdm-binary
    4442 ? S 0:00 /usr/sbin/gdm-binary
    4444 tty7 SLs+ 3:38 /usr/bin/Xorg :0 -audit 0 -auth /var/lib/gdm/:0.Xauth
    6633 pts/0 S+ 0:00 grep gdm
    kill 4444
    the above example assumes gdm is your login manager so substitute whatever you're using, and you can kill the other instances of gdm (in my example processes 4441 and 4442 but don't waste your time on the grep process 6633
    now redo your X config
    (actually you could run this from a terminal from within X and it should have the same effect of dropping you back to console
    Last edited by tj (2008-04-20 09:36:15)

  • Firefox keeps prompting users to disable java plugins How can reinable them through the command line or registry?

    Windows users keep getting prompted about java version being insecure and are advised to disable the plugin. They then complain that java based websites no longer work. Can I disable / prevent this warning feature. And can I re-enable java plugin via command line or script? I need to do this on a large scale and various versions of firefox. Right now I will need to abandon firefox if I cannot easily resolve this. Yes I realize updating to latest version of java is a solution... but this will take too much time now and how long before another security fix for java and then I will have to update yet again.

    Tylerdowner, to say that Firefox 3.6 is no longer supported is not an answer. Apparently, the so-called block deployed for the Mac OS X version of Firefox, created to deal with a vulnerability in Oracle's Java, has now crept into the Windows version. Moreover, it is blocking the latest version of Java, which was not intended according to https://bugzilla.mozilla.org/show_bug.cgi?id=741592. The official text of the block follows:
    Java Plugin has been blocked for your protection.
    Why was it blocked?
    Outdated versions of the Java plugin are vulnerable to an actively exploited security issue. All Mac OS X users are strongly encouraged to update their Java plugin through Software Update, or disable it if no alternatives are available. For more information, please read our blog post or Oracle's Advisory.
    Who is affected?
    All Firefox users who have installed the Java plugin, JRE versions below 1.6.0_31 or between 1.7.0 and 1.7.0_2.
    What does this mean?
    Users are strongly encouraged to disable the problematic add-on or plugin, but may choose to continue using it if they accept the risks described.
    When Mozilla becomes aware of add-ons, plugins, or other third-party software that seriously compromises Firefox security, stability, or performance and meets certain criteria, the software may be blocked from general use. For more information, please read this support article.
    Well, whoever wrote the code to block the Java plug-ins specified above screwed up, since it is blocking even the updated Java plug-in.
    I have an enterprise with many computers, and we had deployed Firefox as our browsing platform. Based on the latest decisions at Mozilla, new version numbering, forced release cycle, and almost all add-on vendors just walking away from the maintainence nightmare created by this decision, I guess it's time to move over to the Dark Side and adopt Google Chrome.

  • How create a sub_menu using the command line.

    Hi,
    I want to create a new menu and forms in runtime mode .
    please gives me the commands details.

    Hi,
    I think I am having a similar question here. I am using Oracle 10g on Windows xp.
    I logged in to Oracle from command prompt. I used command “create directory myFunDir as 'd:/funDir';”. Oracle returns: “Directory created”. But I couldn’t find the directory “myFunDir”! Where is it?
    Thanks.
    Newbie.

  • How to initialize consumer from supplier via the command line ?

    We have a small directory that gets loaded from scratch every night.
    We also setted up replication to a couple of consumers (read only).
    The problem is that since the data is loaded everynight, we get compliants in logs "Replica has a different generation ID than local database"
    I can initialize the consumers via the gui. But how to do it from the command line from the master ? I know that an option is to do a db2ldif and then an ldif2db on the consumer but it's not an option for us.
    I also tried setting the nsds5beginreplicarefresh to start, but that doesn't seem to do a full init.
    There must be a way, as the gui actually does it.
    TIA

    Basically it's very simple. Supposing your replication is already setup and you reload data to your master. If you want the initialization pushed to all the replicas automatically, you can simply setup a flag in all the agreements. This flag is called nsDS5BeginReplicaRefresh.
    Please check the link:
    http://docs.sun.com/source/816-6699-10/confattr.html#18194
    nsDS5BeginReplicaRefresh
    Allows you to initialize a replica. This attribute is absent by default. However, if you add this attribute with a value of start, the server reinitializes the replica and removes the attribute value.
    Property
    Value
    Entry DN
    cn=ReplicationAgreementName,cn=replica,cn="suffixName",
    cn=mapping tree,cn=config
    Valid Range
    stop | start
    Default Value
    N/A
    Syntax
    DirectoryString
    Example
    nsDS5BeginReplicaRefresh: start
    Please note that this value is absent by default and will disappear whenever initialization to replica finished. Next time whenever you want it to happen again, use ldapmodify to set this flag up.
    Also, if you want this happen to all the master's replicas, you have to setup for all the agreements.
    I already tested and it turns out very magic.
    So what you should do is whenver your master get reloaded, when it gets finished, call ldapmodify to set the attribute to be "start".
    Hope it helps!

  • Run javascript (not in a jsx file) from the command line extendscript

    Hi all,
    I was wondering if anyone knew how to run javascript from the command line in Extendscript (meaning Extendscript would be the target application). I know about the -run command line flag in which allows you to run a .jsx script from the command line but what I'm looking for similar syntax to run a script directly without needing to put it in a file. For example I have tried (obviously unsuccessfully):
    C:\Program Files (x86)\Adobe\Adobe ExtendScript Toolkit CC\ExtendScript Toolkit.exe -run "alert('Hello World');"
    Thanks!

    You might be looking for something like this: javascript - Is it possible to execute JSX scripts from outside ExtendScript? - Stack Overflow
    Although that one is about executing JSX files, the solutions given (Applescript as well as COM/VBScript) can be adapted to simply run a javascript code snippet rather than JSX file because the solutions simply call the Adobe app's Applescript/COM API to "execute javascript" (actually execute ExtendScript technically), and in the solution, they using includes to pull in the JSX file. You'd simply replace the include with actual javascript code snippet inserted in.
    Though this would then require you to run a VBScript, Applescript, or other script (that calls the COM/Applescript API) rather than the ESTK command line option.

  • Linux: Pipe to stdout displays on the command line, but does not redirect to file

    Hello all,
    Several years ago, I was given the task of making a LabVIEW application run from the Linux command line with arguments.
    Now I have the same task, and I naively thought, "Sure, no problem."  So, for my stdout output, I used something very similar to the following:
    It seems to work fine in a compiled application, as it always has, and the prescribed string appears on the command line window.  However, the person testing the functionality here remarked that he couldn't successfully redirect output to a file.
    For example:
    If my compiled binary is "LabVIEW_executable", let's say it is called in the following manner:
    /foo/bar> ./LabVIEW_executable >foo.txt
    Since the desired output appears on the command line, you'd intuitively think that it would also appear in foo.txt, but it does not.  After tinkering for a while and coming up with very little in the way of search results, I thought I'd ask here.
    Has anyone ever done this before?
    I am very grateful for any assistance.
    Regards,
    Jim

    Ahhh, thanks a lot!
    Whoops.  Looks like I made a novice mistake.
    Nice icon, by the way. 

  • Passing arguments to osascript from the command line

    I'm just learning how to use the Terminal at the moment and was wondering if anyone knew how to pass parameters from the command line to Applescript via osascript. I'm trying to use this as a function embedded in my .profile file so I don't have to type out the whole line each time I want to use an Applescript.
    Just as an exercise, I'm trying to get osascript to pass a string of text to a dialog box using 'tell application "Finder" to display dialog "$1" '. But all this does is open a dialog box with "$1" in it! Anyone know how to get this to work?

    Neyüm wrote:
    I'm just learning how to use the Terminal at the moment and was wondering if anyone knew how to pass parameters from the command line to Applescript via osascript. I'm trying to use this as a function embedded in my .profile file so I don't have to type out the whole line each time I want to use an Applescript.
    Just as an exercise, I'm trying to get osascript to pass a string of text to a dialog box using 'tell application "Finder" to display dialog "$1" '. But all this does is open a dialog box with "$1" in it! Anyone know how to get this to work?
    http://discussions.apple.com/forum.jspa?forumID=735

  • Capturing the output of a os command line

    I need to capture the output of a os command line executed from one java program and I don't know how can do it.
    For example:
    Runtime.getRuntime().exec("hostid");

    Your suggestion worked very well, just in case that this could interest somebody, this is the complete solution
    Thanks for your help
    import java.io.*;
    public class HostID
    public static void main(String args[]){
    try{
    InputStream in = (Runtime.getRuntime().exec("hostid")).getInputStream();
    byte[] arreglo= new byte[200];
    int cantidad = in.read(arreglo);
    System.out.println(new String(arreglo,0,cantidad));
    } catch (IOException ioe){System.out.println(ioe.getMessage());}
    }

  • How to configure Team explorer 2010 command-line tool in Mac x os. configure shell or system path to include the folder to which (TF client) unzipped archive available.

    How to configure Team explorer 2010 command-line tool in Mac x os.
    Hot to configure shell or system path to include the folder to which (TF client) unzipped archive available. I am new to Mac X OS. Please help.

    Dmitry,
    Thanks for the great writeup!
    I think I've got my universal instant client libraries built correctly.
    I too am using MacBook Pro but I'm getting stuck at building the 32 bit oci8.so
    First problem is my pecl download (ver 1.4.1) did not contain a "configure" file so ./configure failed.
    I used configure from /sw/....... to try to continue.
    Second problem. Using existing configure from /sw/.... I used an appropriate variation of your example command
    (./configure --with-oci8=instantclient,/usr/local/oracle/instantclient_10_2 && make).
    Things look like everything ran OK but The output does NOT include an oci8.so file
    So I guess my question is: Which "configure" should I be using? And if it is not the one on the system under /sw/...
    where would I get it since it doesn't come in the pecl download?

  • How can I open a PDF file and enter a word in the Find field from the command line?

    Hi,
    I want to use a PDF file as the help file of another program.
    I have found somewhere an incomplete description of the command line parameters of Acrobat Reader.
    It described how to open a file and jump to its given page.
    I have written the following batch file based on that.
    rem Open pdf (prm1) with Acrobat reader at given page (prm2)
    "%adobe_rdr%\AcroRd32.exe" /N "zoom=73&page=%2=OpenActions" %1
    The following batch file opens the search dialog:
    rem Open pdf (prm1) with Acrobat reader
    rem and search for something (prm2)
    "%adobe_rdr%\AcroRd32.exe" /N "zoom=73&navpanes=1=OpenActions&search=%2" %1
    I need the simple find field instead of the complicated search window.
    Regards
                   Ferenc

    Not possible.

  • How do I open a PDF to a specific page via the command line?

    Several questions about opening PDFs from the Mac OS X command line:
    1) How do I use the "open" command to open a PDF to a specific page? (I know I can open a document via: open doc_name.pdf)
    2) How do I use the "open" command to pass multiple arguments (page no, zoom scale, view mode, etc...) to open a PDF file in a specific manner?
    3) Does Preview handle the same parameters as Acrobat Reader? If not, what are the differences in options?
    I've spent hours searching for this answer and have come up dry. I've downloaded Adobe's "PDF Open Parameters" document -- it lists all of the parameters I need, however I can't get any of them to work from the command line.
    My goal: Open a PDF from the command line to a specific page. At first glance, I thought this would be simple to do and find -- however, after a lot of searching I haven't found an example on how to do it.
    Anyone have any experience doing this, and care to share?
    Much appreciated! ---> Kelsey

    I don't know of any way to do what you want using the 'open' command. It can probably be done with Applescript, which you could call from a shell script. The Preview application doesn't seem to be scriptable. I don't use Acrobat, so I can't tell you anything about that. Looking through the dictionaries of the apps I do have, it seems that Skim (another PDF viewer) has an AS 'page' class. Below are a couple of links that may get you started. Look for more specific guidance in Applescript forums.
    http://sourceforge.net/apps/mediawiki/skim-app/index.php?title=AppleScript
    http://links.tedpavlic.com/shell_scripts/skim

  • How can I start System Preferences from the command line?

    Hello All,
    I have an issue I'm not quite sure how to solve. I have been tasked within my business environment  with tightening security on a Mac Leopard system and I've been granted Admin Rights to do this on a temporary basis.
    The problem is as follows:
    1) The original Sys Admin that set up this system is gone, no longer available.
    2) He was a Dvorak Keyboard fan and set up the system for a Dvorak Keyboard.
    3) The system actually has a standard Apple keyboard and is marked accordingly, i.e., qwerty (Most Users in the building have stopped using this system altogether - a terrible waste of a good system - even though some of their apps can be run normally (US style qwerty settings). The command line is useless, as is texteditor.app and a few others unless you know Dvorak layout)
    5) When I open System Preferences, the Dvorak keyboard checkbox is grayed out and I cannot change it. There is no lock at the bottom of that particular screen for me to unlock.
    6) Even though I select the US Keyboard at Login, and some apps work accordingly (like MatLab for example) the terminal is borderline useless. I spent over 2 hrs yesterday doing what should have been able to be done in about 30 minutes. I estimate a frustrating and mistake prone additional 8 to 10 hours to do what is normally a a 4 hour job at the command-line.
    7) I do not have the time or desire to re-mark all the keys on the keyboard, particularly since it is not my call to do so, nor do I have the time to re-learn Dvorak touch-typing, and finally I do not want to re-load the entire system. I just want to change the darn keyboard to a standard qwerty keyboard that is somewhat useful in a terminal environment with vi, command line, etc. It's either that or I go mildly insane
    This is frustrating as all get-out. The new Admin logged in and was able to uncheck his Dvorak settings (he is not a UNIX guy, nor is he comfortable om Macs), and we were hoping this was a system wide setting, but No. We re-booted the system, I logged in, still Dvorak, and the checkbox was still grayed out.
    So I figure, short of re-loading the entre system and all the applications necesary, I can either start the Systems Preferences GUI using sudo and hopefully that will change system-wide settings, or I can delete the .AppleSetupDone file and resetup the system (if the keyboard settings are part of the setup) without spending a couple of days reloading everything and re-setting up users, networks, etc.
    Needless to say, I am hoping for the easiest and quickest solution to this extremely frustrating and  aggravating problem.
    Thanks.

    For my situation the following C# code does the job:
        Process.Start(
           @"c:\Program Files\National Instruments\CVI71\cvi.exe",
           @"c:\temp\experiment.c" );
    The file must already exist.

  • How do I create a local account from a network login from the command line?

    I am connecting to my organization's domain using 3rd party software which doesn't allow for using the GUI for creating local accounts.  How can I do this through the command line or is there a better way to script it?  Thanks in advance!

    What you're looking for, I think, is mobile accounts with portable home directories.
    Portable Home Directories in 10.8...: Apple Support Communities
    Configuring OS X Server 10.8 – Open Directory and PHD

  • How do i create a database template from the command line?

    Hi,
    As part of implementing a backup and recovery strategy for a client (including disaster recovery) I want to automate the creation of a database template From an Existing Database (Structure as well as data) via a script that will run every night.
    The background to this is that we will also be using RMAN to take backups of the database concerned but the client does not want to wait while an RMAN backup is restored and so wants an additional level of insurance in the form of a ‘standby’ clone database.
    The idea is that nightly we will run a script that creates a database template from the Existing Database (Structure as well as data) and then transfers the 2 files involved e.g. DB_data_included.dbc and DB_data_included.DFB across to a standby server where they can be used to recreate the database in the event of us needing to after e.g. a complete server failure.
    So I have a couple of questions about this that I would be very grateful if something could answer for me:
    1)     Is it possible? That is, can a database template be created from some utility by supplying a series of parameter=value pairs on the command line?
    2)     If yes how do I go about it, what utility do I use (the emca utility?). and what parameters do I need to supply on the command line to create the template?
    3)     The intention is that the script to create the template will run in the early hours of the morning when no-one is using the database but what state does the database need to be in when the template creation script runs i.e. up, down, mounted and does the creation of a template affect the state of an already up database i.e. if I kick off the template creation script and the database is up will it switch it into mount mode or anything like that? My concern here is that I want to make sure I understand exactly what is going on so that no users or connected external systems are affected?
    Thanks in anticipation of someone being able to guide me on what to do or what documentation to read.
    Also if you require any clarification on what i'm asking please post up your query and i'll respond ASAP.
    Kind Regards,
    George Johnston
    OCP 9i DBA

    Sybrandb,
    Firstly thanks for you reponse.
    However, I don’t agree that dbca only creates empty databases otherwise why does the option to create a template from an existing database (structure as well as data) exist in the dbca wizard?
    I have performed a test case where I have a created a database template including data on one 10g server. I have then used the files generated to recreate that database on a separate server. When the new database is started it is an exact copy of the original. So it’s not empty at all , it’s exactly what the client wants.
    So I don’t agree that I’m gaining zero.
    Why is this approach doomed to fail?
    There a number of reasons why I “just set up a proper standby database”
    1.     Time – I’m on a customer site in a tight engagement where the customer wants maximum value for money. I don’t have standby database skills and the customer isn’t willing to pay for me to learn on the job so please understand the tight circumstances I’m working in.
    2.     Availability – As far as I know the client is running 10.2.0.3.0 standard edition. Correct me if I’m wrong but is standby db available in that edition. Where do I look to check V$OPTION.
    On the RMAN duplicating a database front it’s an area I haven’t used before but I will take a look at it.
    Also please revisit the context of my original posting where I state
    The background to this is that we will also be using RMAN to take backups of the database concerned but the client does not want to wait while an RMAN backup is restored and so wants an additional level of insurance in the form of a ‘standby’ clone database.
    So please understand that this a quick fix that the client wants developed in the minimum time possible in ADDITION to a full nightly RMAN backup being taken.
    In an ideal world I’d have the time to follow best practice but in the real world of on-site customer support I just need to get the job done operating under the customer imposed constraints.
    Many Thanks,
    George Johnston
    OCP 9i DBA

Maybe you are looking for

  • How do I access files that I put in iCloud Drive on my iMac and MacBook Pro, and then access them with ANY iOS device?

    For example, I put some .pdf documents into iCloud Drive. Now I need those files but I'm not home any more----I have an iPhone and iPad at my disposal. They are ALL signed into the same iCloud account and they are all on the same WiFi network. Those

  • How to provide Menu Options like BACK in ALV Grid display?

    Hi Guys,           My problem is after displaying Multiple ALV grids using OO .I was not able to provide Back option and all those are Deactivated onj the Menu bar.So,How to provide those options.?We have a GreenButton with Symbol Correct on that Men

  • Handbrake and iPad 2 - image too stretched

    Hello, I am trying to convert some home-made DVD's (family etc) to video on the ipad. I have ripped using DVD Decrypter, but whenever I use Handbrake too convert to ipad, the image is too squashed (larger black bars at top and bottom). All I want it

  • BAPI for Creating Activity Journal

    Dear Experts,              i am able to create the Activity through standard function module BAPI_ACTIVITYCRM_CREATEMULTI, now i want to create the Activity Journal, how can i create Activity Journal, BAPI_ACTIVITYCRM_CREATEMULTI is the right bapi fo

  • SAP XI on a multi-core, multi-thread server?

    Hi Everyone! Can anyone tell me whether SAP XI can run on a Server whose processor is multi-core, multi thread (4 cores, 8 threads per core, 32 threads)? Thanks in advance! Warm regards, Glenn