Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
runCommand vs. ` vs. on adding vs. rule (Read 8856 times)
Paul Walters
Ex Member




runCommand vs. ` vs. on adding vs. rule
Jun 09th, 2008, 9:10pm
 
I am making a small Tinderbox document to map and track usage across a system with numerous drives.  Among the notes will be regular use snapshots.  For the use, I want to use a "df -H" command to get a nice summary of disc capacity and use.

If I use: Text=`df -H

In the on-add action, it doesn't work.  If I use it in a Rule it does.

Same for runCommand("df -H") - works in a Rule, not in an on-add action.  For my snapshot notes, I don't want to continually update the use stats.

Seems like it should work in the on-add action.  Is my syntax and/or assumption incorrect?
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: runCommand vs. ` vs. on adding vs. rule
Reply #1 - Jun 10th, 2008, 7:29am
 
Just to make sure...are you setting the OnAdd action in the container or in the note? If if you add it to a container, that action is run on any notes/aliases added to the container.  If added to a note that is in a container, it has no effect unless/until that note itself becomes a container.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: runCommand vs. ` vs. on adding vs. rule
Reply #2 - Jun 10th, 2008, 9:29am
 
I tried added the action
Quote:
Text=`df -H

to a container, and it does operate as expected: the Text of each note added to the container is replaced by a synposis of disk use.

A further tip: this will look best if the TextFont of the note is monospaced (Courier, perhaps, or Monaco, or Andale Mono).
Back to top
 
 
WWW   IP Logged
Paul Walters
Ex Member




Re: runCommand vs. ` vs. on adding vs. rule
Reply #3 - Jun 10th, 2008, 9:30am
 
Mark & Mark, I had this OnAdd Action in an adornment, and it does not work for me in 4.2.4:

Text = runCommand("df -H")

I noticed that using the $Text syntax, such as

$Text=runCommand("df -H")

works as expected.  This "$" form works as OnAdd in containers, adornments, and prototypes; and in rules everywhere.

[Added after re-reading Mark B: I created a new document and used both runCommand and the "`" form, each without using $Text, in a container and an adornment, and everything worked fine.  Flummoxed.  In the original documents I was building, I cannot get this to work at all.  In test documents it works.]
Back to top
 
« Last Edit: Jun 10th, 2008, 11:07am by paulwalters »  
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: runCommand vs. ` vs. on adding vs. rule
Reply #4 - Jun 10th, 2008, 11:19am
 
I pasted the action
Quote:
Text = runCommand("df -H")

which I copied from your message into a newly made container, and then added a child to that container.

As I expected, the child did contain the text from this command.

I tried the same thing with an adornment, and it worked correctly as well; when a dragged a new empty note onto the adornment, the note's text was replaced with the file system summary.

Perhaps a typo in the runCommand?
Back to top
 
 
WWW   IP Logged
Paul Walters
Ex Member




Re: runCommand vs. ` vs. on adding vs. rule
Reply #5 - Jun 10th, 2008, 11:33am
 
Typo, or a ghost in this machine!

I tested this by creating a note and opening an info window on that note.  As expected, the word and character count are 0 and 0, respectively.  I drag that note onto the adornment that has the Text=runCommand("df -H") OnAdd action.  In the info window I can see that the word and character count pop up to a number consistent with a df command.  The note's icon in the Explorer view also expands.  So at that point, there seems to be text in the note.  But, the instant I click on the note in Explorer view, the word and character count drop back to 0 and 0, respectively, the icon shrinks, and I see no text.

Perhaps my document is corrupt?  Since it seems to work in new documents I create, I'll start over from the beginning and see if I can make a go at it.
Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: runCommand vs. ` vs. on adding vs. rule
Reply #6 - Jun 10th, 2008, 12:39pm
 
This might be an Explorer View artifact.  Because ExplorerView lets you edit the selected note, ansd because Tinderbox tries to avoid replacing text you're editing with text it is generating, it might think you're in the middle of replacing the note and refuses to overwrite your empty text.
Back to top
 
 
WWW   IP Logged
Paul Walters
Ex Member




Re: runCommand vs. ` vs. on adding vs. rule
Reply #7 - Jun 10th, 2008, 4:24pm
 
These two workarounds result in displayed Text:

Text=runCommand("date")&runCommand("df -H")

or

Text=runCommand("df -H")&myText=$Text

(myText is a string attribute).

The first workaround results in a more informative report, so I'm going with that.  That the second workaround works is strange.  I have a number of other runCommand rules in this document, gathering bits and pieces of system information for my status document - all of which work just fine - but perhaps the event loop doesn't play well with Tinderbox when there are multiple simultaneous command requests.   Go figure.
Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: runCommand vs. ` vs. on adding vs. rule
Reply #8 - Jun 10th, 2008, 4:53pm
 
The plain command works fine for me.

The '&' in your two "workarounds", though, is probably a mistake.  Semicolons delimit commands. If you want to concatenate strings, use "+".
Back to top
 
 
WWW   IP Logged
Pages: 1
Send Topic Print