Results 1 to 3 of 3
  1. #1
    mdthahir is offline Member
    Join Date
    Jul 2007
    Posts
    3
    Rep Power
    0

    Default Need to write a program to execute a list of system commands

    Hi guys,

    I am new to Java and I am currently working on IPsec running on a linux box.

    In order to setup an IPsec connection I need to execute a list of commands such as the following:

    $ ipsec whack --name new
    $ ipsec whack --listen
    $ isec whack --initiate


    Now I want to combine all these into a single program so that whenever I run that program all the above commands get executed. Now I know that it is easier to do in shell scripting but then I won't be able to include my input data, i.e., I need to specify between which 2 hosts the connection is to be made.

    I give this information in the command line, for eg, say runprog 190.175.1.1 190 175.2.2 where the connection is setup between the 2 ip addresses.

    Hence I need to get this information from the command line and include it in the ipsec commands.

    The list of ipsec commands I'll need to execute manually in order to do this will be:

    $ ipsec pluto
    $ ipsec whack --name new --host 190.175.1.1 --to --host 190.175.2.2 --psk
    $ ipsec whack --listen
    $ ipsec whack --initiate


    Looking forward to any help possible. Thanks in advance.

  2. #2
    brianhks is offline Senior Member
    Join Date
    Jul 2007
    Posts
    135
    Rep Power
    0

    Default

    This is still easier to do with a shell script. The script would look like this:
    #! /bin/bash
    ipsec pluto
    ipsec whack --name new --host $1 --to --host $2 --psk
    ipsec whack --listen
    ipsec whack --initiate

    The $1 and $2 represent the first and second params from the command line.

  3. #3
    mdthahir is offline Member
    Join Date
    Jul 2007
    Posts
    3
    Rep Power
    0

    Default

    Thanks a lot for the response.

    I figured out shell scripting is an easier option. That's what I used finally.

Similar Threads

  1. Replies: 0
    Last Post: 04-04-2008, 02:40 PM
  2. Using Runtime to execute external commands
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-05-2008, 09:14 AM
  3. Replies: 0
    Last Post: 10-04-2007, 09:33 PM
  4. Execute a new program in java
    By mathias in forum Advanced Java
    Replies: 1
    Last Post: 07-31-2007, 05:42 AM
  5. Replies: 1
    Last Post: 07-27-2007, 05:46 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
  •