Bash Script for Adding Printers In RHEL 6.7
Ok,
It has been a while since I wrote a bash script and I need a little help. I'm charged with migrating printers from our virtual environment to our all-in-one cloud system. I been adding the printers manually via the lpadmin command, but I'm coming up on a huge migration were I have to add about 100 printers, and my wrist hurt just thinking about adding them manually. I have written a script in bash doing a basic for loop, but I can remember how to make the loop cat more than one file. Code:
#!/bin/bash P.S sorry the code format is wrong. I cant remember how you guys make it all pretty. |
You can cat more than one file simply by giving multiple arguments to cat command (e.g. cat file1 file2 file3 ...)
Since you're doing a variable you can set the variable equal to multiple files: Code:
#!/bin/bash |
What you are saying makes sense, but I can not seem to put it into action. How would I do this with a long lpadmin command?
I dont seem to understand how to make the script assign different variables for the different list. Code:
lpadmin -p "printer_name" -E -v "device_URL" -P "device_ppd" |
Ah, I misunderstood. On rereading I see you're trying to get separate values from 3 separate files for different variables in your lpadmin. Assuming you have the same number of lines in each file with each having a single column you can use the "paste" command to join them together as 3 separate columns. You'd then use a while loop in combination with the "read" command that sets variables based on input.
Code:
#!/bin/bash |
YES!!!!
That did the trick. Thank you so much for your help. You are a life saver. |
All times are GMT -5. The time now is 04:26 AM. |