Mmmh, system_profiler command refuses to save a report anywhere other than the logged in user's home directory, is that normal behaviour? Any way I can get around it?
creation__ joined the channel
squirke has quit
mikedodge04 has quit
gbatye joined the channel
elliotjordan
where's allister when you need him. i'm trying not to grep before awk, but this command seems to require it:
Your user doesn't have rights to write to /Library/Logs/test.xml
msim
I just realised I had an error in my if statement I was using in casper for it, I fixed that and it runs via casper
gneagle
sudo doesn't help with > output redirects
ctdawe
Ah, okay.
msim
Oh, well I learned something new.
elliotjordan
you could write to /tmp and then sudo mv to /Library/Logs
gneagle
You ran system_profiler with elevated rights
GaToRAiD has quit
But the output redirect is still your normal rights
frogor
elliotjordan: awk uses regular expression searches with the forward slash starting/stopping it - so if you try to match a forward slash in the middle of your search, you can either escape it - or just replace it with a period which matches one of any character.
ctdawe
But the subsequent redirect...
bochoven has quit
elliotjordan
now i have my my #TIL of the day courtesy of gneagle!
bochoven joined the channel
frogor
elliotjordan: Unfortunately awk will match itself in that list, which is what the purpose of the grep -v was
msim
Yeah, that's actually really useful to know.
elliotjordan
frogor: right, that's why i thought the grep -v "grep" was necessary
is there an equiv in awk?
gneagle
elliotjordan: Just do what you were doing
it works
don't worry about "never grep before awk" silliness
elliotjordan
gneagle msim: but since casper runs all scripts as root, wouldn't the redirect also belong to root?
frogor
elliotjordan: But in this instance, you can do a trick and just have at least one backslashed forward slash due to the nature of how ps works.
samdm
what is the meaning of not doing a grep before an awk?
elliotjordan: Sure but we never saw msim's script so we can't know wht it was actually doing
Avatharian joined the channel
halloweenhead joined the channel
samdm: Someone told Allister that and he remembered it
frogor
ps will show the literal search including the escaped forward slash '\/' which will now count as *two* characters, which an escaped forward slash will not match
gneagle
He was so proud he wanted to show everyone
frogor
Alternatively you could escape all of them, but it's not necessary beyond having the one.
samdm
could it be that awk is more expensive and if your grep returns nothing it would be pointless?
gneagle
awk can do lots of cool stuff that often means you don't _need_ to grep
frogor
Yeah. It's just one less command in the pipeline
gneagle
But most awking and greping of output is by definition a fragile hack
frogor
If you were going to run it through awk anyways to do field printing, why not also use it for searching
samdm
true
gneagle
So being particular about it seems silly
gbatye joined the channel
"I don't like your fragile hack, use my better fragile hack"
elliotjordan
yeah, seems like grep before awk is actually the simpler option here, even though it too is a hack
gneagle
Agreed
adamcodega
Hehe, whats up elliotjordan
gneagle
You could also grep the output of `killall -s loginwindow`
frogor
hah
Corey84 joined the channel
Also, hope you take into account that grepping / searching for loginwindow will show multiple values if you've got fast user switching enabled.
elliotjordan
yep, accounting for that frogor
CURRENT_USER=$(/usr/bin/stat -f%Su /dev/console)
not perfect, but it does the job w/r/t casper
adamcodega
Yeah you need to know what the output is going to be like before you mangle it.
elliotjordan: what are we doing?
elliotjordan
trying to launch an app in the context of the current user, using a script that runs in root context
squirke joined the channel
as in, casper just updated dropbox and now it needs to relaunch the app
it's all very hacky
gneagle
So is it worth it?
bochoven has quit
elliotjordan
for dropbox, maybe
for the combination of all apps, probably
gneagle
Just let Dropbox update itself...
adamcodega
gneagle: Preach it.
elliotjordan
yep, dropbox does a good job with that lately
unimachead joined the channel
Avatharian has quit
some apps don't
adamcodega
elliotjordan: yeah current user stuff is a !@#$
gneagle
So don't update them while they are in use
That way lies madness
elliotjordan
doing that too. policy runs at startup
lots of people never restart
gneagle
and?
elliotjordan
i've pretty much made up my mind that i'm going to do this. just need to find the best way how. :-)