On Tue, 29 Mar 2005, Mike Galke wrote:
When I go to "Send Unix Command" button and type in "$hostinfo", hit
send, where does that info show up? It doesn't come up on either mine,
nor the target machine.
Not "$hostinfo" -- that would be a variable name. That's useful if
you're writing shell scripts, but it doesn't apply here.
`hostinfo` is a command that lives in your /usr/bin directory; in most
cases, you can run it just by typing "hostinfo" at a command prompt, or
by putting "hostinfo" in the Send UNIX Command feature of ARD. You can
also be explicit about the name by saying "/usr/bin/hostinfo", which
would differentiate it from any other commands with the same name.
The "$ ...something..." convention is meant to imply a Unix command
prompt, which conventionally has a $ at the beginning. For a shell with
root priviliges, # is conventional, so writing "# ...something..." is a
way of saying that the command being described needs to run either as
root or under the "sudo" command, as "$ sudo ...something...". In this
case, we're not discussing commands that need administrator or
superuser
access, so I just used a $ to denote the prompt, rather than a #. If
you're running a command that spills across multiple lines, the prompt
becomes a >, so something like
$ thing \
another thing \
some more things
$
implies one big multi-line statement that has been broken into separate
lines for clarity.
The same applies for the other commands I mentioned in the earlier
message. Wherever the first character is a $, omit it if you're pasting
that into a shell or into ARD. With everything else, I was just showing
you sample output you can expect by running these commands in Terminal.
Further, commands can be chained together.
* With a ';', you're saying
"first do this command; then do this command"
$ hostinfo ; sw_vers
* With a '|', you're saying
"do this command, and send the output to the next one"
$ hostinfo | grep Processor
* With a '||', you're saying
"do this command, and if it fails do the next one"
$ hostinfo | grep Processor || echo "No processor here???"
* With a '&&', you're saying
"do this command, and if it works do the next one"
$ hostinfo | grep Processor && echo "This machine has a
processor."
* With text following a command's name, you're saying
"run this command, using what follows as arguments"
$ echo Hello world
$ echo -n Hello world
* With 'single quotes', you're saying
"run this command, using the literal quoted text as an argument"
$ echo "Today is 'date'."
* With `backtick quotes`, you're saying
"run this command, `using the output from this one as arguments`"
$ echo Today is `date`.
* With "double quotes", you're saying
"run this command, and if any variables or backtick quotes are
inside, show their contents rather than what they are literally"
$ echo "Today is `date`."
* With a \ (backslash) at the end of the line, you're saying
"this line and the one after it should be treated as one line"
$ echo "The grand old duke of york \
he had ten thousand men \
he marched them up the fields \
and he marched them down again"
Try some of these in Terminal to get a feel for what's going on.
So if you want both "hostinfo" and "sw_vers", try "hostinfo ; sw_vers"
Or if you want to filter the output of "hostinfo", for example to just
find out how much memory there is, you can do this:
$ hostinfo | grep 'Primary memory available'
Primary memory available: 1024.00 megabytes.
$
If you want to get only the data from that result, you can whittle it
down more with a command like 'awk', 'sed', or 'perl'. In this case,
I'll use 'awk' to get the 4th item in the line:
$ hostinfo | grep 'Primary memory available' | awk '{print $4}'
1024.00
$
If you want to run this everywhere in a way that shows you which
computer this is describing, you might prefix the command. Here's one
way to do that:
$ echo -n "`hostname`: " ; \
hostinfo | grep 'Primary memory available' | awk '{print $4}'
macgarnicle: 1024.00
$
If you saved this and ran it on all hosts, you could get a get a report
that listed every machine in turn:
mac1: 1024.00
mac2: 1024.00
oldmac1: 256.00
ancientmac1: 64.00
Etc.
Let me know (on list, please) if you have other questions. If you're
really curious about this stuff, there are some decent Unix for OSX
users books out there, as well as generic Unix books that can help. If
you just want to be able to extract certain information, I can try to
show you commands that will do what you need.
--
Chris Devers
np: 'Hell On Wheels'
by Paul McCartney
from '[???]'
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Remote-desktop mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/remote-desktop/
email@hidden
This email sent to email@hidden