Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Dec 15, 2018 11:10 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Slow Shell Command
PostPosted: Sat Jan 19, 2013 10:23 am 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
sh.execute "/usr/sbin/ioreg -l | /usr/bin/grep IOPlatformSerialNumber"


I am executing this shell command in an application.

On all of my computers this takes less than 1/2 second. but on a clients computer it takes WELL OVER A MINUTE

Anyone have any idea WHY? Does it have something to do with ADMIN vs "regular user"? I have ONLY an admin account on my personal computer. He has an Admin and two user accounts (one for him, one for his wife).. just guessing here



FYI... this alternative is SLOW on MY machines (above takes me 0.5 secs, below takes me 28 seconds]

sh.execute "/usr/sbin/system_profiler | /usr/bin/grep ""Serial Number (system):"""

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Slow Shell Command
PostPosted: Sat Jan 19, 2013 12:00 pm 
Offline
User avatar

Joined: Mon Feb 05, 2007 5:21 pm
Posts: 600
Location: New York, NY
What about this?
sh.execute "/usr/sbin/system_profiler SPHardwareDataType | /usr/bin/grep ""Serial Number (system):"""

This only takes a fraction of a second to run here.

If you wanted to keep it all in RS code, try this:
sh.execute "/usr/sbin/system_profiler SPHardwareDataType"

dim rx as new RegEx
rx.SearchPattern = "Serial Number \(system\): (.*)$"
dim match as RegExMatch = rx.Search( sh.Result )
dim sn as string
if match <> nil then sn = match.SubExpressionString( 1 )

_________________
Kem Tekinay
MacTechnologies Consulting
http://www.mactechnologies.com/

Need to develop, test, and refine regular expressions? Try RegExRX.


Top
 Profile  
Reply with quote  
 Post subject: Re: Slow Shell Command
PostPosted: Sat Jan 19, 2013 12:05 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
Thanks.

I tried that on my machine, and it dropped from 28 seconds to a fraction of a second....

Am going to send that to my client and see if it helps.....


No idea why the first version is quick for me, and slow for him?

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Slow Shell Command
PostPosted: Sat Jan 19, 2013 12:08 pm 
Offline
User avatar

Joined: Mon Feb 05, 2007 5:21 pm
Posts: 600
Location: New York, NY
None. The first version is pretty quick here too, but, like you, I am using an admin account.

_________________
Kem Tekinay
MacTechnologies Consulting
http://www.mactechnologies.com/

Need to develop, test, and refine regular expressions? Try RegExRX.


Top
 Profile  
Reply with quote  
 Post subject: Re: Slow Shell Command
PostPosted: Sat Jan 19, 2013 12:19 pm 
Offline
User avatar

Joined: Mon Feb 05, 2007 5:21 pm
Posts: 600
Location: New York, NY
Actually, one thought. Maybe it has to do with some peripheral(s) attached to your client's Mac.

_________________
Kem Tekinay
MacTechnologies Consulting
http://www.mactechnologies.com/

Need to develop, test, and refine regular expressions? Try RegExRX.


Top
 Profile  
Reply with quote  
 Post subject: Re: Slow Shell Command
PostPosted: Sat Jan 19, 2013 12:25 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
using System Profiler, that might make sense.... but not with "/usr/sbin/ioreg -l | /usr/bin/grep IOPlatformSerialNumber"

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Slow Shell Command
PostPosted: Sat Jan 19, 2013 1:09 pm 
Offline

Joined: Tue Mar 23, 2010 8:44 pm
Posts: 673
Maybe it's a scope problem?
Have you tried making sh global and performing your tasks?

Did you properly test for <>nil or whatever before trying to use the shell
?


Wow, I've forgotten so much Realbasic since I haven't been coding in it for a long time.


I'm also down for the count with the flu. wonderful.

:(


Top
 Profile  
Reply with quote  
 Post subject: Re: Slow Shell Command
PostPosted: Sat Jan 19, 2013 1:18 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
The shell command for the client does return the correct result.. it just takes over a minute to do so

Dim sh As New Shell
Dim s As String
Dim x As Integer
#If TargetMacOS
//sh.execute "/usr/sbin/ioreg -l | /usr/bin/grep IOPlatformSerialNumber"
sh.execute "/usr/sbin/system_profiler SPHardwareDataType | /usr/bin/grep ""Serial Number (system):"""
s=sh.Result
x=InStr(s,"=")
if x=0 then x=instr(s,":")
If x>0 Then s=ReplaceAll(Trim(Mid(s,x+1)),Chr(34),"")
#end


haven't sent the client the 2nd execute command... but the 1st one (commented) takes over a minute for that one line

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Slow Shell Command
PostPosted: Sat Jan 19, 2013 1:25 pm 
Offline

Joined: Tue Mar 23, 2010 8:44 pm
Posts: 673
DaveS wrote:
The shell command for the client does return the correct result.. it just takes over a minute to do so



Right, I understood it's getting the correct result but taking forever.

Maybe in addition to testing for <> nil and changing scope to global (if you're going to do that) you could have your customer copy paste the shell command in terminal and see how long it takes?

I use something similar in fairly large project. I'll need to think about swapping out that code with the regex code (thanks ktekinay). However that might make the project un-compatible with older versions of RS which I may need due to bugs.


Top
 Profile  
Reply with quote  
 Post subject: Re: Slow Shell Command
PostPosted: Sat Jan 19, 2013 1:32 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
I am confused..

Test what for NIL? if Shell was nil the command would never work.... Not sure how/why making Shell global would be any different... Not arguing... just wondering?

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Slow Shell Command
PostPosted: Sat Jan 19, 2013 1:36 pm 
Offline

Joined: Tue Mar 23, 2010 8:44 pm
Posts: 673
DaveS wrote:
I am confused..

Test what for NIL? if Shell was nil the command would never work.... Not sure how/why making Shell global would be any different... Not arguing... just wondering?



I'm out of touch with RB because it's been a long time since I've really coded with it but I seem to remember the proper way was to test sh<>nil and sh.exists before using it to avoid possible errors and weird stuff.

Also by using a local variable for sh isn't it possible it's not working correctly (taking a long time) because it's getting scoped out?

I remember sockets get really weird and I thought shell does sometimes also.

Maybe search for some shell notes in the documentation and on here.

Maybe I'm remembering it wrong.

Btw, does it have to do with which shell is being used?
I seem to remember not every shell has access to all of the same shell programs.

I know your data is coming back but maybe those things are slowing it down somehow.......?


Top
 Profile  
Reply with quote  
 Post subject: Re: Slow Shell Command
PostPosted: Sat Jan 19, 2013 1:50 pm 
Offline
User avatar

Joined: Mon Feb 05, 2007 5:21 pm
Posts: 600
Location: New York, NY
J.Sh3ppard wrote:
I use something similar in fairly large project. I'll need to think about swapping out that code with the regex code (thanks ktekinay). However that might make the project un-compatible with older versions of RS which I may need due to bugs.

If I recall, that regular expression would work all the way back to when the RegEx class was introduced to REALbasic.

_________________
Kem Tekinay
MacTechnologies Consulting
http://www.mactechnologies.com/

Need to develop, test, and refine regular expressions? Try RegExRX.


Top
 Profile  
Reply with quote  
 Post subject: Re: Slow Shell Command
PostPosted: Sat Jan 19, 2013 4:14 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
J.Sh3ppard wrote:
Maybe I'm remembering it wrong.

Definitely. But we'll chalk it up to the flu meds. :)


Top
 Profile  
Reply with quote  
 Post subject: Re: Slow Shell Command
PostPosted: Mon Jan 21, 2013 6:15 am 
Offline

Joined: Thu Oct 13, 2005 1:05 am
Posts: 101
DaveS wrote:
Thanks.

.....

No idea why the first version is quick for me, and slow for him?


ioreg output length (you read through) depends much (in length) of Mac type (and whats connected like USB devices,....). Minor length diffs by OS X version diffs.
Also CPU speed maybe give HUGE time diff to some client - if he has an old Mac (Single Core Intel cpu or even worse an PPC Mac) it may takes 2-10 times longer to compute the ioreg output as with on modern C2D / i5/i7 / XEON powered mac


Top
 Profile  
Reply with quote  
 Post subject: Re: Slow Shell Command
PostPosted: Mon Jan 21, 2013 10:24 am 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
Well he doesn't have an OLD MAc, because he is running Mt.Lion....

but I sent him code with this in it.. and it worked in 1/2 second for him... so we are good... Thanks!!

sh.execute "/usr/sbin/system_profiler SPHardwareDataType | /usr/bin/grep ""Serial Number (system):"""

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group