ksh question, loops


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ksh question, loops
# 1  
Old 06-21-2005
ksh question, loops

i want to add about 60 printers using a ksh script.
i am having trouble though, i am reading the input from the hosts file and using the lpadmin command to add like so:

lpadmin -p [printername] -v /dev/null -m netstandard -o dest=[ipaddy]

i want printername and ipaddy to come from the hosts file, i am having some trouble getting the right variables in the right spots, i know this is about a 2 minute script for some of you, so any assistance will be greatly appreciated.


thanks,
Brian
# 2  
Old 06-21-2005
assuming /etc/host file format:
Code:
#!/bin/ksh
while read ip host junk
do
   lpadmin -p "${host}" -v /dev/null -m netstandard -o dest="${ip}"
done < myPrinterFile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh - Need Help Reducing Nested Loops

Hello, I pulled out some old code from an unfinished project the other day and wanted to stream line it better. I know anything beyond a double loop is usually bad practice, and I came up with some logic for later that would no longer require the first loop in the following code that works: ... (5 Replies)
Discussion started by: Azrael
5 Replies

2. Shell Programming and Scripting

Two for loops in ksh script only one not executing

Hello, I have two "for loops" in my script and the second one is not executing the way i want. Script: #!/bin/ksh IFS=' ' printf "Enter Account name: " read A B C D E F G H I J K L M N O for i in ${A} ${B} ${C} ${D} ${E} ${F} ${G} ${H} ${I} ${J} ${K} ${L} ${M} ${N} ${O};... (3 Replies)
Discussion started by: seekryts15
3 Replies

3. Homework & Coursework Questions

Loops question

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: When the code is run only the first loop is utilized and it skips the following when it should move on after the... (2 Replies)
Discussion started by: TwistedKitty
2 Replies

4. Shell Programming and Scripting

KSH nested loops?

KSH isn't my strong suit but it's what my company has to offer. I've got a script with two nested loops, a FOR and UNTIL, and that works fine. When I add a CASE into the mix I end up getting "Unexpected 'done' at line xx" errors. Any suggestions on this? for divi in at ce ci cm co de di fl... (9 Replies)
Discussion started by: mrice
9 Replies

5. UNIX for Dummies Questions & Answers

Bourne-sh (not bash) question about nested loops and sed

Here's the input: alpha, numeric or alphanumeric string ("line 1 string") numeric string ("line 2 string") numeric string ("line 3 string") numeric string ("line 4 string") ... where - each numeric string is in a pattern that can be matched with RE but - there can be any number of... (2 Replies)
Discussion started by: uiop44
2 Replies

6. Shell Programming and Scripting

Nested while loops (ksh scripting)

You can use one while inside another? I made the following script (without really knowing if I can use two while) to get 3 numbers different from each other at random: num1=$(( $RANDOM % 10 )) num2=$num1 while do num2=$(( $RANDOM % 10 )) done num3=$num1 while do while do... (1 Reply)
Discussion started by: ale.dle
1 Replies

7. UNIX for Dummies Questions & Answers

Passing KSH variable to AWK with two loops

Hi, I need some help to figure out why an outer for loop KSH variable does not decode in AWK but inner for loop does. Below is my code, If I hard code variable 'SUBSEQ' in AWK it works but if I try to pass the SUBSEQ from KSH, it does not and when I pass the variable 'NAM' from KSH it works: I... (1 Reply)
Discussion started by: chowdhut
1 Replies

8. Shell Programming and Scripting

ksh if block question

Hi, I am looking at a script, and it contains lines like: if ] ... This is getting me confused. Why do we need $ before (echo $* | egrep -c 'DG')? Why can't we simply have: if ] ... i.e. no $ here before the ()... Thanks. J (3 Replies)
Discussion started by: JamesByars
3 Replies

9. UNIX for Dummies Questions & Answers

ksh question

How can I know if my system has ksh feature? #!/usr/bin/ksh Which command we allow me to see? Please advise! (1 Reply)
Discussion started by: bobo
1 Replies

10. Shell Programming and Scripting

Question about KSH line.

Wondering what this line meant, especially the 2>&1 and ${RUN_DIR} parts: ${RUN_DIR}/<filename> 2>&1 Where <filename> is the location and name of a file. (1 Reply)
Discussion started by: CapsuleCorpJX
1 Replies
Login or Register to Ask a Question