Stubborn Bash App won't Redirect to variable - any ideas???

Hello All!

Am trying to script a control app to add features to the popular app HandBrake, but have run into a problem with the Bash app Sample.

I need to capture the call graph it generates, but it INSISTS on writing to the /tmp file, and nothing seems to work.

here is what I have:


set handbrakeActivity to (do shell script "var=$(sample HandBrake 1); echo $var") as list

Now the txt file it produces in /tmp has all the data I need, like the following, but I can’t seem to redirect it.


Analysis of sampling pid 501 every 10.000000 milliseconds
Call graph:
100 Thread_0f13
100 start
100 _start
100 NSApplicationMain
100 -[NSApplication run]
100 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]
100 _DPSNextEvent
100 BlockUntilNextEventMatchingListInMode
100 ReceiveNextEventCommon
100 RunCurrentEventLoopInMode
100 CFRunLoopRunSpecific
100 __CFRunLoopRun
99 mach_msg
99 mach_msg_trap
99 mach_msg_trap
1 __CFRunLoopDoObservers
1 _handleWindowNeedsDisplay
1 -[NSWindow displayIfNeeded]
1 -[NSView displayIfNeeded]
1 -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:]
1 -[NSView lockFocus]
1 -[NSView lockFocusIfCanDraw]
1 -[NSView _focusFromView:withContext:]
1 -[NSFocusState flush]
1 CGGStateReset
1 CGGStateRenderingReset
1 renderingStateCopy
1 renderingStateCopy

Not sure if this is sterr or what, but the manual for Sample states that you can specify the output to a new path. Is it possible to foo an output path into a variable??

Really Stumped on this one! :o

UPDATE!!!

My Uber-Brainy Linux buddies had the answer. For bash apps the don’t output the desired info to stdout, or stderr, you can do this: -file /dev/stdout :slight_smile:

As great as OSX is, there are times I feel that Linux is really the future. Those guys know their $#!t

They have to, otherwise the system is useless.

A do shell script, apart from how to use the command properly, has little to with AppleScript. Just don’t get your hopes up too high on MS when you have questions about the shell. There are plenty other forums that will help you including Apple’s own discussion board regarding shell commands. Next time just read the manual more carefully because the manual of sample is clearly describing the -file option :wink:

Thanks for coming back and sharing the solution. Great that ‘those guys’ helped you.