Change ip from user input


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Change ip from user input
# 1  
Old 04-19-2010
Change ip from user input

I have 2 Servers IP:
1)10.1.1.27
2)10.1.2.27

#more /etc/postfix/transport

Domain.com smtp:ServerIP

Now i want to change the smtp:ServerIP according to user interaction:
# 2  
Old 04-19-2010
Can you please be more specific on what is required? perhapes, provide an i/p and expected o/p
# 3  
Old 04-19-2010
Does your "transport" file contain only that one line?
If yes, here is my solution, a nifty menu:

Code:
#!/bin/bash
while [ answer != "0" ]
do
clear
echo ""
echo " 1. use 10.1.1.27"
echo " 2. use 10.1.2.27"
echo " 3. show config file"
echo " 0. exit"
echo ""
read -p " -> " answer
    case $answer in
       0) break ;;
       1) echo "Domain.com smtp:10.1.1.27" > /etc/postfix/transport && 
          echo "" && echo "config file was updated!" ;;
       2) echo "Domain.com smtp:10.1.2.27" > /etc/postfix/transport &&
          echo "" && echo "config file was updated!" ;;
       3) echo "" && cat /etc/postfix/transport ;;
   esac
   echo ""
   echo "press RETURN for continue"
   read key
done
exit 0

Of course the user who will work with this menu will have to have appropriate privileges for the "transport" file.

Kind regards,
pc
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Change Date Input :-

I have Below Input :- X1=03 ### Hour Y1=20160405 ## Date Z1=3 ## I want to Back 3 Hour Output List=03 02 01 Y1=20160405 Input:- X1=02 ### Hour Y1=20160405 ## Date Z1=4 ## I want to Back 4 Hour Output:- List=02 01 24 23 Y1=20160404 ### Date Will Change (13 Replies)
Discussion started by: asavaliya
13 Replies

2. Shell Programming and Scripting

User input and run awk using the input

I am trying to allow a user to enter in text and then store that text in a variable $gene to run in an awk command in which those values are used to run some calculations. I am getting syntax errors however, when I try. Thank you :). The awk runs great if it is a pre-defined file that is used,... (7 Replies)
Discussion started by: cmccabe
7 Replies

3. Shell Programming and Scripting

Script interacts with user , based on user input it operates

i have a script which takes input from user, if user gives either Y/y then it should continue, else it should quit by displaying user cancelled. #!/bin/sh echo " Enter your choice to continue y/Y OR n/N to quit " read A if then echo " user requested to continue " ##some commands... (7 Replies)
Discussion started by: only4satish
7 Replies

4. Shell Programming and Scripting

How to get the user input recursively until the user provides valid input

Hi, echo "Enter file name of input file list along with absolute path : " read inputFileList if then for string in `cat inputFileList` do echo $string done else echo " file does not exist" fi From the above code, if the user enters a invalid file... (1 Reply)
Discussion started by: i.srini89
1 Replies

5. AIX

How to change normal user id to LDAP user id?

If I create a new user id test: mkuser id=400 test then I want it to LDAP user: chuser -R LDAP SYSTEM=LDAP registry=LDAP test It shows: 3004-687 User "test" does not exist. How to do? (4 Replies)
Discussion started by: rainbow_bean
4 Replies

6. Shell Programming and Scripting

Change in Input feed based on condition file

Sorry Guys for not being able to explain in one of my earlier post. I am now putting my requirement with the input file and desired output file. In the below input file - Transaction code is at position 31:40. Business code is from position 318:321 TSCM00000005837 ... (7 Replies)
Discussion started by: varunrbs
7 Replies

7. Debian

change the input method .

i open the google search and want to search something, now , i want to change the input method ,but i don't know how to change the default input. the default is english, how to exchange with others. thanks in advance (0 Replies)
Discussion started by: runeveryday
0 Replies

8. UNIX for Dummies Questions & Answers

change user> to user@host> ssh prompt

Hi, I was wondering how to change the prompt for my ssh login. At the moment it is like user> while I'd like it to be as user@host> It is in the .bash_profile or .ssh ??? Thanks (2 Replies)
Discussion started by: pmasterkim
2 Replies

9. Shell Programming and Scripting

change standard input ?

Dear... I have a scrpit that contains multiple read command.... when I run the script I have to enter 3 variables so that I can get the output.. but, I dont want to put those 3 inputs manually every time... I want to make a shell that reads the 3 inputs from a file. the script name is... (4 Replies)
Discussion started by: yahyaaa
4 Replies

10. Shell Programming and Scripting

How do i change to super user then revert back to ordinary user ,using shell script?

Hi all, I am trying to eject the cdrom from a livecd after certain stage... Now assuming that it is possible to eject,please consider my issue!!! The OS boots into a regular user by default...so i am unable to use the eject command to push out the drive... However if i try pfexec eject it... (3 Replies)
Discussion started by: wrapster
3 Replies
Login or Register to Ask a Question