LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 07-09-2003, 02:31 PM   #1
chrisk5527
Member
 
Registered: Oct 2002
Location: Michigan
Distribution: Slackware Linux 10.0
Posts: 289

Rep: Reputation: 30
Shell Scripting Question


I'm trying to automate the removal of a user from a mailing list. If I try these commands from the command line everything works great, but when I run my script, it doesn't work a bit.

echo "Enter username:"
read username

egrep -v '($user)' mailing.list > temp
mv temp mailing.list

All the paths and permissions are correct, I'm running the script as root within my own directory so neither of those are an issue. Any ideas?

Thanks,
Chris
 
Old 07-09-2003, 02:36 PM   #2
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 199Reputation: 199
Error messages when running? And what do you mean by "work a bit" ? Like it half works or something.. ?
 
Old 07-09-2003, 02:52 PM   #3
chrisk5527
Member
 
Registered: Oct 2002
Location: Michigan
Distribution: Slackware Linux 10.0
Posts: 289

Original Poster
Rep: Reputation: 30
"it doesn't work a bit." <- which means it doesnt work at all

No error messages either
 
Old 07-09-2003, 03:59 PM   #4
Jose Muņiz
Member
 
Registered: Jul 2003
Location: Mexico City
Distribution: Slackware 9.1, SuSE 9.1
Posts: 248

Rep: Reputation: 31
Have you noticed you read "username" and use "user" in your egrep command?
 
Old 07-09-2003, 04:00 PM   #5
Rumblefish
Member
 
Registered: Jun 2003
Location: Delaware
Distribution: Redhat 7.0, 7.2, 8.0, 9.0, FreeBSD 4.6.2
Posts: 51

Rep: Reputation: 15
You're reading user input into a UDV called "username" and then trying to use "$user" in your egrep command. Methinks that may be an issue?
 
Old 07-09-2003, 04:05 PM   #6
Jose Muņiz
Member
 
Registered: Jul 2003
Location: Mexico City
Distribution: Slackware 9.1, SuSE 9.1
Posts: 248

Rep: Reputation: 31
I said it first, I must get the credits
 
Old 07-09-2003, 04:06 PM   #7
chrisk5527
Member
 
Registered: Oct 2002
Location: Michigan
Distribution: Slackware Linux 10.0
Posts: 289

Original Poster
Rep: Reputation: 30
My bad, I was just trying to give an example of the command, but in the script below, it looks the same as the script I'm having trouble with.

echo "Enter username:"
read user

egrep -v '($user)' mailing.list > temp
mv temp mailing.list
 
Old 07-09-2003, 04:09 PM   #8
Jose Muņiz
Member
 
Registered: Jul 2003
Location: Mexico City
Distribution: Slackware 9.1, SuSE 9.1
Posts: 248

Rep: Reputation: 31
hm... does your list remain untouched as if you hadn't run the script on it?
 
Old 07-09-2003, 04:09 PM   #9
chrisk5527
Member
 
Registered: Oct 2002
Location: Michigan
Distribution: Slackware Linux 10.0
Posts: 289

Original Poster
Rep: Reputation: 30
it doesnt matter because it was a typo.
 
Old 07-09-2003, 04:12 PM   #10
chrisk5527
Member
 
Registered: Oct 2002
Location: Michigan
Distribution: Slackware Linux 10.0
Posts: 289

Original Poster
Rep: Reputation: 30
Tthe timestamp on the file is updated, but the user is not being removed from the list. So that means that the script does actually do something, but not what I want.
 
Old 07-09-2003, 04:19 PM   #11
Rumblefish
Member
 
Registered: Jun 2003
Location: Delaware
Distribution: Redhat 7.0, 7.2, 8.0, 9.0, FreeBSD 4.6.2
Posts: 51

Rep: Reputation: 15
Show me a sample line (with all vital data removed, of course) from your mailing.list file. It's definitely something with the matching, because the file is being dumped to "temp" and then moved over to mail.list again. egrep is just not matching that particular line.
 
Old 07-09-2003, 04:34 PM   #12
chrisk5527
Member
 
Registered: Oct 2002
Location: Michigan
Distribution: Slackware Linux 10.0
Posts: 289

Original Poster
Rep: Reputation: 30
I got it, what I did was I removied the '( )' from the egrep command so it looks like:

egrep -v $user mailing.list > temp
mv temp mailing.list

Thanks for everyones help...
 
Old 07-09-2003, 04:36 PM   #13
Rumblefish
Member
 
Registered: Jun 2003
Location: Delaware
Distribution: Redhat 7.0, 7.2, 8.0, 9.0, FreeBSD 4.6.2
Posts: 51

Rep: Reputation: 15
That's where I was about to go

Best of luck!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
a shell-scripting question: mrchaos Slackware 3 09-22-2005 12:00 PM
Shell scripting question. dragin33 Linux - General 2 08-11-2004 06:17 PM
Shell Scripting Question Onyx^ Linux - General 5 04-27-2004 11:37 AM
Shell Scripting Question b_vasu Linux - Newbie 1 11-21-2003 03:10 PM
Shell Scripting Question jester_69 Programming 13 11-05-2003 07:55 PM


All times are GMT -5. The time now is 04:52 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration