LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Shell Scripting Question (https://www.linuxquestions.org/questions/linux-general-1/shell-scripting-question-71331/)

chrisk5527 07-09-2003 01:31 PM

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

trickykid 07-09-2003 01:36 PM

Error messages when running? And what do you mean by "work a bit" ? Like it half works or something.. ? :confused:

chrisk5527 07-09-2003 01:52 PM

"it doesn't work a bit." <- which means it doesnt work at all

No error messages either

Jose Muņiz 07-09-2003 02:59 PM

Have you noticed you read "username" and use "user" in your egrep command?

Rumblefish 07-09-2003 03:00 PM

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?

Jose Muņiz 07-09-2003 03:05 PM

I said it first, I must get the credits :D

chrisk5527 07-09-2003 03:06 PM

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

Jose Muņiz 07-09-2003 03:09 PM

hm... does your list remain untouched as if you hadn't run the script on it?

chrisk5527 07-09-2003 03:09 PM

it doesnt matter because it was a typo.

chrisk5527 07-09-2003 03:12 PM

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.

Rumblefish 07-09-2003 03:19 PM

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.

chrisk5527 07-09-2003 03:34 PM

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...

Rumblefish 07-09-2003 03:36 PM

That's where I was about to go :)

Best of luck!


All times are GMT -5. The time now is 03:54 AM.