LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 09-23-2010, 12:29 PM   #1
mmcc0912
Member
 
Registered: Mar 2010
Posts: 37

Rep: Reputation: 0
Parsing delimited file and variable scripting.


I did some searches and after a few hours was able to get what I needed. What I didn't find was a fully encompased means of what I'm used to in the windows world in working with delimted files. Hopefully this is helpful to others and if there is something better or leaner way, even better.

We have an issue where managing printers, just viewing on RHEL w/ sys-conf-prtr we lose any number of, up to ~30 printers from lpadmin. Rather than stare and compare to find the missing ones, I wanted to make an intuitive script. This is what I came up with.

Code:
#!/bin/sh

while IFS="," read Prntr IP; do
  lpstat -a | grep $Prntr > /dev/null 2>&1
    if test $? != "0"; then
    lpadmin -p $Prntr -u allow:all -v "socket://$IP:9100" -E
    echo "     ..... $Prntr was installed"
    else
    echo "Printer $Prntr is installed"
    fi
done < prntrs.lst | more +2
Here's the output that I get:

Printer test1 is installed
Printer test2 is installed
Printer test3 is installed
Printer test4 is installed
Printer test5 is installed
..... test8 was installed
..... test9 was installed

Thanks all ..
 
Old 09-24-2010, 07:58 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Since you solved the issue you should mark it resolved by going to thread tools. That way anyone searching in future can find it.
 
Old 09-25-2010, 01:45 PM   #3
mmcc0912
Member
 
Registered: Mar 2010
Posts: 37

Original Poster
Rep: Reputation: 0
Right on MensaWater. I also read yesterday that there is a better place for it. Not sure if it can be moved...

Was hoping there would be some additional information on it, I'm new to Linux and going through the learning curve of the different shells and scripting.

Thanks.
 
Old 09-25-2010, 01:49 PM   #4
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Hi there!

You mean, "a better place for this thread"?

If so, I'd suggest you put in the move request, and have this moved to the /Programming forum, as that would be, in my opinion, the best place for this. If you think another forum would be better, just ask, and a moderator will figure out if it belongs there, or where it would be better located.

To ask for a thread to be moved (or for any other thread/post-related request), just click the REPORT button on your first post in the thread, and send a note to us; we'll take care of it.

Cheers!
Sasha
 
  


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
[SOLVED] rear file names to creat a comma delimited file GRS63 Linux - Software 7 02-04-2011 12:40 AM
Bash scripting: parsing a text file character-by-character Completely Clueless Programming 13 08-12-2009 09:07 AM
column re-alignment - space delimited to comma delimited hattori.hanzo Linux - Newbie 9 03-05-2009 12:54 AM
Scripting: accessing a variable stored in a variable? tomolesonjr Linux - Newbie 5 05-05-2006 08:47 PM
Parsing a tab delimited text file jajanes Programming 9 08-08-2003 10:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:34 AM.

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