Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-27-2007, 06:28 PM
Member
 
Join Date: Jul 2007
Posts: 3
mdthahir is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-27-2007, 06:54 PM
Senior Member
 
Join Date: Jul 2007
Posts: 134
brianhks will become famous soon enough
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.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 08-07-2007, 08:22 PM
Member
 
Join Date: Jul 2007
Posts: 3
mdthahir is on a distinguished road
Thanks a lot for the response.

I figured out shell scripting is an easier option. That's what I used finally.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to execute an External Program through Java program Java Tip java.io 0 04-04-2008 03:40 PM
Using Runtime to execute external commands Java Tip Java Tips 0 02-05-2008 10:14 AM
How to execute an External Program through Java program JavaBean Java Tips 0 10-04-2007 10:33 PM
Execute a new program in java mathias Advanced Java 1 07-31-2007 06:42 AM
Need to write a program to execute a list of system commands mdthahir Networking 1 07-27-2007 06:46 PM


All times are GMT +3. The time now is 10:22 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org