LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-05-2005, 02:21 PM   #1
VirtualGod
LQ Newbie
 
Registered: Aug 2005
Posts: 2

Rep: Reputation: 0
bash script


My knowledge in bash scripting is about medium not very advanced and all so I am not attempting to make a connection limiter but what I want to make is a script that checks the irc connections off a certain user and takes some actions, mostly of this I know how to do but I got stuck at this :
I write in a file we will call it users.allow the following:
Virtual 5
Test 7
Server 9
Power 2

This will be the file that will hold the limit of the users from where the script reads when checks.
So my script will read from this file and if the user Virtual for example has more than 5 connections he will kill all his processes that are running in background.
But what what I don`t know how to do is make the script read, for example if I start the script he starts reading from users.allow, I want it to read an take each line, first taking the line 1 with user Virtual and setting to a variable the number it has near it like $allow=5, next after it finishes the process for Virtual takes Test etc.
So my need would be how can I get the script to read first line, do the process I will make for it, then take the next line and do the process for that user until end of file. And also after taking the first line for example reading only the first block in it, the one with user so it can set $user=Virtual and then to take the path with the number.
I would greatly apreciate if you can help me with this issue, I really need this script but didn`t know what to look in the manuals for etc.
Also if you know a similar script please let me know.
 
Old 08-06-2005, 06:52 AM   #2
vladmihaisima
Member
 
Registered: Oct 2002
Location: Delft, Netherlands
Distribution: Gentoo
Posts: 196

Rep: Reputation: 33
Try :

Code:
cat users.allow | while read U N ; do
  echo $U $N ; 
done
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash Script zaicheke Programming 3 11-07-2004 06:32 PM
bash script how to? Lleb_KCir Programming 11 05-21-2004 07:03 PM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
bash script - incrementing a filename in a script tslinux Programming 10 08-05-2003 11:58 PM
bash script prob: how can i tell the script that a 'dd' has finished? Frustin Linux - General 2 04-02-2003 05:34 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration