##osx-server

/

      • thered has quit
      • halloweenhead joined the channel
      • asher^ joined the channel
      • bruienne
        evening
      • ctdawe
        Hey bruienne
      • tbridge_ joined the channel
      • halloweenhead has quit
      • tbridge has quit
      • tsuter joined the channel
      • tsuter has quit
      • tsuter joined the channel
      • tbridge joined the channel
      • vmiller has quit
      • vmiller joined the channel
      • tsuter has quit
      • tsuter joined the channel
      • tbridge_ has quit
      • bruienne
        howdy ctdawe
      • chilcote has quit
      • ropav has quit
      • squirke has quit
      • squirke joined the channel
      • msim joined the channel
      • msim
        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:
      • ps auxww | grep "/System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow" | grep -v "grep" | awk '{print $2}'
      • Willfon has quit
      • Willfon joined the channel
      • msim: even when you pipe output in terminal? seems weird
      • gbatye_ has quit
      • msim
        Yeah, I get permission denied whenever I attempt to save it elsewhere, including when attempting a sudo, doesn't even prompt for a password
      • gneagle
        elliotjordan: Are you doing launchctl bsexec hackery?
      • elliotjordan
        gneagle: yep, trying it out
      • msim: this works for me: system_profiler SPHardwareDataType > /Users/Shared/test.txt
      • chilcote joined the channel
      • msim
        Hm.
      • I'm doing an xml, could you try that?
      • elliotjordan
        msim: i didn't even have to sudo
      • sure, 1 sec
      • msim: yep, this works too: system_profiler SPHardwareDataType -xml > /Users/Shared/test.xml
      • gneagle
        msim: If you aren't running it as root, you can save it only places you have write rights...
      • elliotjordan
        msim: the same should be true of any output, though not just system_profiler. does echo "hello world" > /Users/Shared/hello.txt work for you?
      • tsuter has quit
      • msim
        Hmm, I initially attempted running it via casper, without getting anywhere, which is why I moved to trying the command in terminal
      • elliotjordan
        casper runs scripts as root, so you should have permission to save wherever
      • msim
        Yeah, that's what I thought
      • Avatharian has quit
      • elliotjordan
        but let's back up one step. what are you trying to get out of system_profiler that you can't already get out of casper?
      • msim
        Have a case open with Apple, they want a system report
      • mikedodge04 joined the channel
      • tsuter joined the channel
      • mikedodge04 has quit
      • ropav joined the channel
      • I'll do a little more testing myself and poke my head back in later.
      • elliotjordan
        msim: fair enough
      • gneagle
        msim: elliotjordan showed you the exact commands he tried; perhaps you could do the same
      • tbridge_ joined the channel
      • msim
        Yeah, they worked, but I realised that's because /Users/Shared/ is writeable for anyone
      • elliotjordan: If you try save it anywhere out of the /Users/ folder /Library/Logs/ for example, with a sudo, what do you get?
      • mikedodge04 joined the channel
      • rtrouton joined the channel
      • gbatye has quit
      • elliotjordan
        hmm, interesting. doesn't work
      • sudo system_profiler SPHardwareDataType -xml > /Library/Logs/test.xml
      • -bash: /Library/Logs/test.xml: Permission denied
      • ctdawe
        Same result here.
      • msim
        Yeah, that's what I was seeing
      • frogor
        elliotjordan: ps auxww | awk '/System.Library.CoreServices.loginwindow.app.Contents.MacOS.loginwindow/ {print $2}'
      • tbridge has quit
      • gneagle
        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?
      • frogor
        elliotjordan: ps auxww | awk '/System.Library.CoreServices.loginwindow.app.Contents.MacOS\/loginwindow/ {print $2}'
      • samdm
        is there actual reasoning there?
      • gneagle
        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. :-)
      • adamcodega
        19:53 up 30 days
      • tbridge_ has quit