![]() |
yeah i thought about that to, that software_profiler doesnt
have to show info in that particular, so I now using the sed "translation" to nr in my specific order, I also fixed so Machine Name and CPU get on the same row. TrumpetPower whould you like to give me a example how to "assign the values to variables", maybe thats a good thing to learn! =) Mikael Quote:
|
Quote:
Just do the same thing for Computer Name, Serial Number, and the like. Then, write out each of those in the order that you like. Of course, what you wound up doing with numbers and sort will accomplish the same thing in the end. It looks ``good enough'' to me. If this is the sort of thing you'll be doing a lot of, I'd recommend a couple books. First is /The UNIX Programming Environment/ by Brian Kernighan and Rob Pike. Next is /Learning Perl/ by Randal Schwartz and Tom Christiansen. Both are excellent introductions to their respective topics. Once you're comfortable with those, you'll have most of the programming skills required by most of the Unix system administration tasks you'll come across. Oh, sure, they're both introductory. And, when it comes right down to it, they both just scratch the surface, really. But, in the real world, you rarely have to go deep. And, if you know how and where to scratch, going deep usually isn't too hard, given a bit of patience. Cheers, b& |
I doesnt do that much of script but it think its fun to learn,
so a book might be a good innvestment! I tried the script at work and didnt get the same output so i had to add some more variables just like suggested, when became varibles active, is it when i call for them or are they read-in when the script starts? Now i using system_profiler three times, is this really the right way? Without complex the script too much... If i did: echo "$info" "$harddrive" in the beginning somehow harddrive output did get on the same row as the last from info is it anyway to control that, i did solve it by putting that at the end? Quote:
|
Quote:
Cheers, b& |
Quote:
Just invoke it and capture all of its output in a variable. Then use that variable in subsequent statements to extract what you need. sysprof_output = `system_profiler` But I would second TrumpetPower's recommendation to use Perl for this sort of thing. It makes it much easier. But of course that is a longer term solution as you would need to spend a few days/weeks learning Perl - but that would be a useful investment if you will do any other system admin stuff in the future. |
This is the finalscript i think, learning som Perl might by good.
Also fun to learn what you can/cant do easily with bash. =) Thanks once again Mikael Quote:
|
You are still running system_profiler several times in that script.
What I had suggested was to execute system_profiler once (by having it inside back-quotes and assign the result to a variable: sysprof_output=`system_profiler` Then to extract things from the text that is now in the variable $sysprof_output, you would do something like: info=`echo $sysprof_output | egrep "Computer Name|Serial Number|System Version|Memory" | head -4` |
is this the right thing im getting it right, so i missed the backquotes?:
Quote:
|
| All times are GMT -5. The time now is 10:30 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.