Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to make a recursive script

Status
Not open for further replies.

MoreFeo

Technical User
Nov 29, 2002
547
ES
Hi, I'm trying to make a menu in AIX so an operator can move the tape from one LPAR to another.
What I need is to take the output from:
lsdev -l rmt0 -F parent
The output will be something like:
scsiX
So I need to take this output and put it in another lsdev:
lsdev -l scsiX -F parent
And so on till the output is like pciX.
Then I'll have to do "rmdev -l pciX -R".
I have no experience in UNIX scripting, and I don't know how to start, so I'll be thankful if can help me.

Thanks
 
Start with something like
Code:
#!/bin/ksh -xv

# start with dev set to rmt0
dev=rmt0

while ! expr "$dev" : "pci." # expr checks for strings like pci.
do
  dev=$(lsdev -Cl $dev -F parent) # dev becomes it parent
done
# dev is now somthing like pci<one letter>

rmdev -l $dev -R # Shouldn't there ba an 'are you sure?'

Ceci n'est pas une signature
Columb Healy
 
Thanks a lot, seems good, I'm going to give it a try.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top