1844894 Members
1814 Online
110233 Solutions
New Discussion

Help with Shell Script

 
SOLVED
Go to solution
James M. Easterling
Occasional Contributor

Help with Shell Script

Hi All,

I need help writing a script that will do the following:

1. Read a text file that contains logical printer names.

2. Use each printer name pulled from the file (one printer name per line) until EOF on a series of commands.

Anys suggestions?

James
4 REPLIES 4
John Strang
Regular Advisor

Re: Help with Shell Script

Hi James,

You could use something like this as a basis:

for i in `cat file`
do
echo $i
done

In this example the "echo $i" line would be replaced by whatever command(s) you wanted to run.

I hope this helps a little,

John
If you never make a mistake you'll never make anything.
Dietmar Konermann
Honored Contributor

Re: Help with Shell Script

I would use something like this...

while read printer; do
# do the magic, e.g.:
echo This is $printer
done < file

Best regards...
Dietmar.
"Logic is the beginning of wisdom; not the end." -- Spock (Star Trek VI: The Undiscovered Country)
Pete Randall
Outstanding Contributor
Solution

Re: Help with Shell Script

James,

Here's a script along those lines - I use it to add all the printers to a new machine but you can adapt it.

Pete

Pete
Pete Randall
Outstanding Contributor

Re: Help with Shell Script

James

And here's the printer list

Pete

Pete