Sponsored Content
Top Forums Shell Programming and Scripting Help :: Simple Shell Scripting Post 302432388 by Ghadamyari on Friday 25th of June 2010 01:48:05 AM
Old 06-25-2010
Help :: Simple Shell Scripting

Hello,

I want to find the "IP-OF-SERVER" in /etc/squid/squid.conf And replace it with The IP of server.
I know this command returns the IP of server :
Code:
ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'

And I can replace with sed. :
Code:
sed -i 's/IP-OF-SERVER/#REPLACEMENT/g' /etc/squid/squid.conf

How I can combine the above commands together so that it replaces IP-OF-SERVER phrase with the ip of server automatically ?
Sometimes the code :
Code:
ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 |  awk '{ print $1}'

returns more than 1 ip if the server has more than 1 ip.
I just want to replace IP-OF-SERVER phrase with the first ip in list.


Best Regards
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

any tutorials on simple scripting?

i'm not looking for anything that deals with "if-then" scripts. i'd like something simple on how to run a series of processes. for example the following: 1. ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-current/tar_files/ 2. lcd / 3. get pkgsrc.tar.gz 4. bye 5. cd /usr 6. rm -rf pkgsrc 7. cd... (3 Replies)
Discussion started by: xyyz
3 Replies

2. Shell Programming and Scripting

Help with simple scripting actions

Hi, I am a beginner in unix shell scripting. I wanted simple information like 1- How to know what are the number of command line options given for the script file? 2- How to check if a variable value is interger or string? 3- How to use awk to replace value of a variable For example I... (5 Replies)
Discussion started by: Nads
5 Replies

3. Shell Programming and Scripting

simple scripting question

I am new to scropting and I am just trying to work on a few simple things.... Using sh I want to do something similar to the follwoing run a simple command like a dig then I want it to get the server that it is authorotative and return it to me saying somehting like xx.xx is authorotative. I am... (3 Replies)
Discussion started by: gennaro
3 Replies

4. Shell Programming and Scripting

difference between AIX shell scripting and Unix shell scripting.

please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 Replies

5. Shell Programming and Scripting

HELP me PLS... Simple Scripting!

this is my script.... SQL> select * from dba_profiles 2 where resource_name in ('FAILED_LOGIN_ATTEMPTS','PASSWORD_LOCK_TIME') 3 order by profile; and this is the output... PROFILE RESOURCE_NAME RESOURCE... (2 Replies)
Discussion started by: liezer
2 Replies

6. Shell Programming and Scripting

Simple Scripting Problem

Hi there, I was trying to add a line of text in the middle line of a file. I have counted the lines in the file, and then I divide it into 2, after that I am stuck on how am I suppose to append the line on that file? When I tried to use this command 'second line >> filename' it appends it at... (3 Replies)
Discussion started by: felixwhoals
3 Replies

7. Shell Programming and Scripting

using XML::simple in shell scripting

CPAN provide xml::simple module which can be used to generate XML files. can i use this module in shell scripting? how? plzz give me an example to generate xml file using this module . you can also use some other module.. BUT SHELL SCRIPTING SHOULD ONLY BE USED (4 Replies)
Discussion started by: cynosure2009
4 Replies

8. Shell Programming and Scripting

Simple scripting.

echo "what is your username?" read username echo $username echo /home/$username $backup="backup" $restore="restore" # # if then echo "No username provided" else echo "hi $username would you like to backup or restore?" read userrequest echo $userrequest if then ... (4 Replies)
Discussion started by: EwanD
4 Replies

9. Homework & Coursework Questions

Simple Shell Scripting

1. The problem statement, all variables and given/known data: An argument example: ../path/cse/lab3/remove Right now, it's printing out all the directory and files in 'lab3'. I want it to print out all the files in 'remove'. I'm not sure how to do that. (I want to use a for loop) 2.... (2 Replies)
Discussion started by: spider-man
2 Replies

10. OS X (Apple)

A simple reminder script for beginners to shell scripting.

(Apologies for any typos.) Well hands up those who have been in the following situation(s):- Your partner, (in my case the missus), sees that you are messing with your machine and says something like, "can you keep an eye on the dinner, I am going out shopping", and you look up glazed eyed... (3 Replies)
Discussion started by: wisecracker
3 Replies
ext_file_userip_acl(8)					      System Manager's Manual					    ext_file_userip_acl(8)

NAME
ext_file_userip_acl - Restrict users to certain IP addresses, using a text file backend. Version 1.0 SYNOPSIS
ext_file_userip_acl [-dh] [-f file name ] DESCRIPTION
ext_file_userip_acl is an installed binary. An external helper for the Squid external acl scheme. It works by reading a pair composed by an IP address and an username on STDIN and matching it against a configuration file. OPTIONS
-d Write debug info to stderr. -f file Configuration file to load. -h Display the binary help and command line syntax info using stderr. CONFIGURATION
The squid.conf configuration for the external ACL should be: external_acl_type type-name %SRC %LOGIN /path/to/ext_file_userip_acl -f /path/to/config.file If the helper program finds a matching username/ip in the configuration file, it returns OK , otherwise it returns ERR . The configuration file format is as follows: ip_addr[/netmask] username|@group|ALL|NONE Where ip_addr is a dotted quad format IP address, the netmask must be in dotted quad format too. When the second parameter is prefixed with an @ , the program will lookup the /etc/group file entry for the specified username. There are other two directives, ALL and NONE , which mean AUTHOR
This program was written by Rodrigo Campos <rodrigo@geekbunker.org> This manual was written by Rodrigo Campos <rodrigo@geekbunker.org> Amos Jeffries <amosjeffries@squid-cache.org> COPYRIGHT
This program and documentation is copyright to the authors named above. Distributed under the GNU General Public License (GNU GPL) version 2 or later (GPLv2+). QUESTIONS
Questions on the usage of this program can be sent to the Squid Users mailing list <squid-users@squid-cache.org> REPORTING BUGS
Bug reports need to be made in English. See http://wiki.squid-cache.org/SquidFaq/BugReporting for details of what you need to include with your bug report. Report bugs or bug fixes using http://bugs.squid-cache.org/ Report serious security bugs to Squid Bugs <squid-bugs@squid-cache.org> Report ideas for new improvements to the Squid Developers mailing list <squid-dev@squid-cache.org> SEE ALSO
squid(8), GPL(7), The Squid FAQ wiki http://wiki.squid-cache.org/SquidFaq The Squid Configuration Manual http://www.squid-cache.org/Doc/config/ ext_file_userip_acl(8)
All times are GMT -4. The time now is 01:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy