Results 1 to 3 of 3
  1. #1
    Sebaslott is offline Member
    Join Date
    Jul 2011
    Location
    San Salvador
    Posts
    3
    Rep Power
    0

    Default Problem with shell cmd in a JAVA api

    Hi, is a pleassure for me belong to the community.

    Well, I have a problem when I want to execute a shell cmd in a JAVA api.
    I want to execute: "echo -n 0 > /dev/motor" to a device, but when I write "echo", this show in the console " 0 > /dev/motor"
    doesn't execute the command in the device file.

    this is the instruction in the code that I wrote:

    Process p = Runtime.getRuntime().exec("echo 0 > /dev/motor");

    Is there another way to write into the device file, without use "echo"?


    P.D.
    Sorry for my english.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,785
    Rep Power
    7

    Default

    Not sure what you are trying to do but all the echo command does is echo(reprints) the text back to the screen. Which is exactly what you observed.

  3. #3
    Sebaslott is offline Member
    Join Date
    Jul 2011
    Location
    San Salvador
    Posts
    3
    Rep Power
    0

    Default

    With the ">" I redirect the "-n 0" to a device file "/dev/motor". I have been create that device file to handle a device.
    So, if a write into the device file "echo -n 0 > /dev/motor" directly from the console, I don't have any problem, cause doesn't show me in the screen that arguments, if it does in the device file.
    But when I use that command from the Java api, shows me in the screen, not in the device file the arguments.

Similar Threads

  1. Java Virtual Shell - API
    By hardcorebadger in forum Advanced Java
    Replies: 0
    Last Post: 04-17-2011, 04:38 AM
  2. Java & shell scripting
    By kswapnadevi in forum Advanced Java
    Replies: 12
    Last Post: 11-21-2010, 06:41 AM
  3. Java Applet Shell script
    By karthikm897 in forum Java Applets
    Replies: 5
    Last Post: 08-18-2009, 04:42 AM
  4. Replies: 4
    Last Post: 06-24-2009, 06:34 AM
  5. Shell Sort in Java
    By Java Tip in forum Algorithms
    Replies: 0
    Last Post: 04-15-2008, 07:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •