The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
perl + array and incrementing number Optimus_P Shell Programming and Scripting 5 07-18-2008 03:55 AM
Port num incrementing coolkid Shell Programming and Scripting 5 05-28-2008 06:51 PM
shell script help: sorting, incrementing environment variables and stuff secoif Shell Programming and Scripting 1 05-08-2008 08:04 AM
New iteration of for-loop without incrementing? jeriryan87 Shell Programming and Scripting 0 07-02-2007 03:13 PM
incrementing a for loop run_time_error Shell Programming and Scripting 2 03-28-2005 03:45 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 06-05-2008
coolkid coolkid is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 69
Port incrementing using one file

Hi
I wrote this script with the help of you guyz.My next challenge is to increment the port using single file.So far iam using this code to increment hp1 and hp2 .To increment port numbers, iam using two different files (.default_port_hp1 and .default_port_hp2).The challenge for me is to use single file and increment the ports.


-------------
echo -n "Enter hp1 port: "
read hp1
if [ -z $hp1 ]
then

default_port_file=.default_port_hp1
default_port_value=80

get_default_port()
{
if [ -f $default_port_file ]
then
default_port=$(<$default_port_file)
else
default_port=$default_port_value
fi
}
set_default_port() {
if [[ $1 > ${default_port:-$default_port_value} ]]
then
echo $1 > $default_port_file
fi
}
get_default_port
echo "---Using [$default_port] as default port-- : "
read hp1

hp1=${hp1:-$default_port}
echo "Port number used = $hp1"

set_default_port $((hp1+1))
fi

--

echo -n "Enter hp2 port: "
read hp2
if [ -z $hp2 ]
then

default_port_file=.default_port_hp2
default_port_value=443

get_default_port()
{
if [ -f $default_port_file ]
then
default_port=$(<$default_port_file)
else
default_port=$default_port_value
fi
}
set_default_port() {
if [[ $1 > ${default_port:-$default_port_value} ]]
then
echo $1 > $default_port_file
fi
}
get_default_port
echo "---Using [$default_port] as default port-- : "
read https_port

hp2=${hp2:-$default_port}
echo "Port number used = $hp2"

set_default_port $((hp2+1))
fi
----------------

Appreciate your help guyz

--Cool
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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

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




All times are GMT -4. The time now is 12:59 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0