Command line applications

Hi,
does anybody know how to create a class that represents a command line application that would use a previously created class's methods and variables?
Jamie

Is this what you're after?
You can compile these 2 together as is with InUser.java - though better to compile the class In.java seperately then you will be able to use it elsewhereimport java.io.*;
// Note: this class has NO "main()" so it cannot work alone
class In{
   private static InputStreamReader isr = new InputStreamReader(System.in);
   private static BufferedReader in = new BufferedReader(isr);
   public static void prompt(String s) {
      System.out.print(s);
      System.out.flush();
   public static String getString(){
      String str = null;
      try {
         str = in.readLine();
      catch (IOException e){
         System.out.println("Error: In.Read() "+e.getMessage());
         System.exit(0);
   return str;
   public static int getInt(){
      int ii = 0;
         try {
         ii = Integer.parseInt(in.readLine() );
      catch (NumberFormatException nfe){
         System.out.println("Error: the number is not convertable to an int");
      catch (IOException e){
         System.out.println("Error: In.Read() "+e.getMessage());
         System.exit(0);
   return ii;
   public static double getDouble(){
      double dd = 0D;
         try {
            dd = Double.parseDouble(in.readLine() );
         catch (NumberFormatException nfe){
            System.out.println("Error: the number is not convertable to a double");
         catch (IOException e){
            System.out.println("Error: In.Read() "+e.getMessage());
            System.exit(0);
   return dd;
// And the user with file with a main signature:
public class InUser{
   public static void main(String[]args){
      System.out.println("\nExample 'In.java' with Readln:");
      In.prompt("Please enter your name: ");
      String name = In.getString();
      System.out.println("Welcome "+name); 
      In.prompt("Please enter a whole number: ");  
      int ii = In.getInt();
      System.out.println("The number squared is "+(ii*ii)); 
      In.prompt("Please enter a fraction number: ");  
      double dd = In.getDouble();
      System.out.println("The numbers square root is " +Math.sqrt(dd));    
}

Similar Messages

  • KeyListener for a command line application

    Hi, I'm currently writing a small command line application aimed at interacting with a database. I would like to implement features such as an automatic completion of the names with the TAB key. My problem is that the objects that sends KeyEvent are AWT components, and they do that when they have the focus. So I was wondering if any of you had already done such a thing. Until now, I tried lots of things, but there is no way I can catch a KeyEvent within the command line...
    Souk

    Write your own input routine that internally reads a character at a time instead of a complete line or string and test the character for tab etc. and take the appropriate action. This also means you will have to/can implement editing keys.
    If there is a Java class that has an dictionary to compare input with I do not know, because the last time I wrote a tool without gui was in 1985.
    Regards
    SH

  • Telnet Server or Command Line Applications

    Hi,
    Bit of a random question to ask seeing as no one has asked it before...but...
    Is there a TELNET SERVER or command line application around for the N series phones? I'm keen on doing some console work with my N82 to explore the symbian interface more.
    Any ideas?
    Owned: Nokia 3510i, Nokia 3120, Nokia 6230i, Nokia 6233, Nokia N73, Nokia N82.
    Current: Nokia N900!

    24-Mar-2008 02:25 PM
    psychomania wrote:
    This has been posted a few times recently for other models and I think someone posted a link to a useful app that works.
    Are you sure of this, Psycho?
    I've seen links to telnet and ssh CLIENTS for S60 here, not for servers.
    Message Edited by grschinon on 24-Mar-2008 02:38 PM
    Was this post helpful? If so, please click on the white "Kudos!" star below. Thank you!

  • Can the command line application be extended?

    I would like to add command like keys etc..Is this possible?

    Correct me if I am wrong, from what I understand, beanShell is a scripting language which interprets the Java language. Yes, I could connect to coherence cache and run any commands I want. However, that won't include the commands which are already prefined in the tangosol command line, would it?
    If I am wrong, I would appreciate if you could show me an example of beanShell and the command line application.

  • Develop a command-line application using LabVIEW

    Hi,
             Is it possible to generate a command line(CLI) executable using LabVIEW? This CLI exe will be called with certain command line arguments by another application (written in Visual Basic). The LabVIEW Run time engine can be installed separately on the host PC.
    Thanks for your help
    Siddharth 
    Solved!
    Go to Solution.

    There is an example that ships with LabVIEW that shows how to read the command line arguements from an application. THe name of the VI is CommandLine.vi. It is extremely basic though. The power of command line arguements really comes from how you define and parse them. I recommend allowing your command line arguements to be order independent and that they require a label. For comand lines I prefer to use a single letter for the label. Full words are nice but then your command line gets very long. For the applications that we write we allow both the '/' (DOS/Windows style) and the '-' (Unix/Linux style) to designate a command line label.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Command Line Application Usage

    Can I use the command line app (coherence.cmd) to query values in an out of process cache? If so how would I go about that?

    Hi Karim,
    Let's assume you have a distributed cache named "Test1" on the cache servers. You can start the command line app on a cache client (localstorage=false) and join the same named cache that is running on the cache servers by typing the following command at the prompt:
    cache Test1
    From the prompt you can type the following command to display cache entries in this particular cache:
    list
    A list of available commands can be found by typing "help" at the prompt or here on the website here.
    I hope this helps.
    Best regards,
    Gary
    Tangosol, Inc.

  • PHP include path for command line applications

    I'm packaging my first contribution to the AUR: a package for Boris, a tiny REPL for PHP.
    The issue I'm finding is that it includes a file relative to where the bin is and it somewhat conflicts with Arch's recommendation for using /usr/lib/pkgname for shared files. You can see the offending line here: https://github.com/d11wtq/boris/blob/ma … n/boris#L6
    I fixed it with sed, but I'm not happy with the solution I wrote. I hoped for PHP shared libraries to have a $PATH such as Python packages, but it seems like it doesn't (by default). See my pkgbuild here: http://sprunge.us/TYgj

    I do it using the registry.  Here is a post where I have a AutoIt EXE scan for what versions of the runtime engine are installed.  And then it runs an EXE that is compatible with the run-time engine or development environment installed.
    http://lavag.org/topic/17803-run-exe-based-on-installed-run-time/
    But you can also do it from a VI.  Attached is a VI that will find the Run-Time versions installed and development with path to the EXE/DLL.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.
    Attachments:
    LabVIEW Versions Installed Registry.vi ‏37 KB

  • How to setup my c# command line application to a remote oracle database?

    Hi all,
    I will like to ask, how do I setup my C# program to be able to connect to a remote oracle database?
    More information:
    - I have an oracle database express version running on my PC.
    - I am able to run and get data from the database on the same PC.
    - But when I bring my application over to another PC within the same LAN. It does not run and given me an error stating "The provider is not compatible with the version of Oracle client".
    What do I need to do on the Client PC so that I am able to communicate back to the server database?
    Many thanks!

    This is the XE forum, not the .NET programming forum, but this might be helpful:
    http://www.codeproject.com/Articles/18692/Instant-Oracle-Using-C

  • Command line interaction - piecemeal!

    Hi All
    I am using "Calling System Exec.vi". Lets say you have a command line app where you have to interact with it over the command line (e.g the command line is the applications UI) The app prompts the user for input for example "Press L to load" and then provides output, e.g. "Load Successful" and these "questions and answers" may occur a number of times.
    From what I can understand this VI is geared towards running the command line application and entering all input (standard inpu) and getting all output (standard output) within a single execution of the Calling System Exec.vi
    What i need to be able to do is open the app but then enter the input and retrieve the output on a  piecemeal basis, at will, without having to wait for the overall execution of the vi to end and\or having to retrieve the standard output in one big lump when it does end. Is this possible, if so how?
    The nearest analogy I can provide to describe what I want to do is when you are communicating with an instrument, you first open it and then you write to it (standard input) to get it to perform some action, and then you read from it (standard output) to get a response. Finally when your done you close it.
    I have a feeling that this is looking like a DLL but because this is a third party .exe I cannot obtain a DLL so this is my only option.
    Thanks for your help.

    This question has been brought up before. Did you try a search?
    http://forums.ni.com/t5/LabVIEW/Controlling-the-STDIN-STDOUT-of-a-legacy-application-in-LabVIEW/m-p/...

  • Terminal.app command line for bluetooth

    Hi,
    Are there any command line applications to monitor or change bluetooth status? For example I use "scselect" to examine and change Network locations.
    Thanks!

    Try->
    apropos bluetooth
    Most likely you need to operate on .plist (preference file) to change the status.

  • Package command line app with AIR app

    Forgive me if I seem completely dense, but I've been googling and forum finding and hair pulling all day on this.
    I wrote a command line application and I call it from my air application.  It all works just fine, but right now the location of the command line application is hard coded.  I want to know:
    1) What is the actionscript that allows me to refer my nativeProcess call to a an application that is packaged with the air app when I export?
    2) Where do I place the command line application in the file system of flash builder to bundle it with everything when I export?
    I realize it'll be different for mac and windows, but I need to do both.  I'm starting with the mac.  Right now as far as I know I can put the command line app in the source folder and that all ends up in the .app/contents/resources folder, but I'm not exactly sure how to reference that in actionscript or if I can or if I should?  I don't know.  Clue me in?

    Can you not use File.applicationDirectory.url as a base?

  • Execute a job in Tidal from SAP command line

    I am looking for an example of a script to execute from an SAP Unix server command line that will start the execution of a batch job in Tidal???

    Hello Jennifer,
    What version of BusinessObjects Enterprise would you be using?
    There's no out-of-the-box command-line utility for scheduling reports. 
    Options are:
    Schedule using the [BusinessObjects Enterprise SDK|http://devlibrary.businessobjects.com/BusinessObjectsXIR2SP2/en/en/BOE_SDK/default.htm] using Java or .NET code
    Schedule using the [Business Process BI|http://devlibrary.businessobjects.com/BusinessObjectsXIR2SP2/en/en/WS_SDK/wssdk_portal/doc/wssdk_bpbi_doc.pdf] Web Services.
    One restriction on using the SDK is that it's tested/fully support only in web applications, and not desktop/command-line applications.
    Sincerely,
    Ted ueda

  • Labview command-line interface

    Hi,
    I have another simple Labview question.   I am trying to determine if Labview is suitable for my purposes.  I have no data acquisiton needs and Labview was suggested to me as a language for GUI development.  I am going to start learning Labview to give it a fair shake for GUI development, because I have some experience in C# and Java.  However, the graphical programming aspect of Labview might be advantageous.  My question is Can Labview be used to develop a command-line application?
    Thanks for your help,
    Will

    OK, so you just need a command-line version of the application you already have? LabVIEW has an application method that allows you to get the command-line arguments passed into a LabVIEW app:
    This will allow you to call a LabVIEW app from the command line and pass in some arguments. The LabVIEW app doesn't need to display a GUI.
    Note that when I say "LabVIEW app" I mean code that you've compiled into an application that you run with the LabVIEW Runtime Engine. I'm not referring to the LabVIEW application itself.
    Message Edited by smercurio_fc on 03-06-2008 12:28 PM
    Attachments:
    Example_VI_BD.png ‏1 KB

  • Launching command line app

    Imagemagick is a command line application for graphics
    opperations. I'd like to be able to control this (launch windows
    command line scripts) from within Director.
    Is this possible?
    Thanks

    Valentin's free ShellXtra sounds like a good fit for you:
    http://staff.dasdeck.de/valentin/xtras/shell/

  • Command-line interaction

    Hello,
    I am using LabVIEW 6.1 for an application on linux. I wish to use the command line 'sftp' client to do secure ftp transfers. I've been investigating how to do this with LabVIEW and I've come up with the following solution that *almost* works.
    I'm using a utility called "Expect" from expect.nist.gov, which is based on Tcl. I've created a script that works great when I execute it from my shell prompt. However, when I use the LabVIEW System Exec function, I can see the script executing, and then it simply stops when it attempts to spawn the sftp process.
    I was wondering if anyone knows of a way around this. I'm also willing to consider alternate approaches to my problem of interacting with a command-line application.
    Thanks,
    David Moerman, Advanced Measurments Inc

    Ah, a weirdness with sftp. I ran a test like this on my machine:
    # begin typing
    mkfifo /tmp/test
    ftp < /tmp/test
    cat > /tmp/test
    open ftp.ni.com
    cd /incoming
    ls
    ^D
    # end typing ^D, is control, D of course
    You should see the results as you type the commands to cat (cat keeps the pipe open, until ^D). You should be able to do something similar in LabVIEW with the pipe commands.
    As long as you don't close the pipe, then ftp should stay running, even if there is nothing to read in the pipe. FTP shouldn't close the pipe, rather it should wait syncronously until there is something to read.
    But when I tried it with sftp (from openssh), it would only work if it did not need to ask me for a password (either due to host based a
    uthentication, or having already provided a passphrash). If it needed a password, before it would read from the pipe, it would undo the stdin I specified (with the pipe), and actually read the password from the interactive shell. After correctly entering the password (from the shell that executed sftp, not the pipe), it would continue as normal and accept commands from the pipe.
    I hope some of this helps you in the future.

Maybe you are looking for