(Question) Having mushclient do remote tasks and outputting it on screen.

Posted by Angelomcm on Tue 17 Feb 2004 10:59 AM — 4 posts, 16,014 views.

#0
I was wondering if something is possible and/or doable.
I have totally no programming language knowledge, yet
bear with me a little.

Scenario:

I have a file which
contains a bunch of items, an item a line.
Would it be technically possible to run a command/trigger whatever with an argument, and have it compared to the textfile ? Eventually echo'ing all word matches onscreen?


ie:
i type the command "Greptext blue" in my mushclient prompt.
Next, a routine would check my item text for every line
containing "blue" and echo it onscreen.

It seems easily doable on unix clients using grep and cat/echo, i wonder about mushclient.

Thank you for reading.


Sorry if i made it a little complicated, English is my 3rd language.
Greece #1
You can read a file from the disk, and searching a line for a word is easy, so yes, it's about 10 lines of code... Unfortunately I'm in a hurry now and I can't give you the code, but I will check back later :(
Australia Forum Administrator #2
This example alias does what you asked, however it does not do any command (eg. copy files).


<aliases>
  <alias
   match="grep *"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>Dim FSO, TexttFile, sContents, sFileName, LineArray, L, Count

  sFileName = GetVariable ("filename")

'
'  Get a FileSystemObject
'
  Set FSO = CreateObject("Scripting.FileSystemObject")

'
'  Open the file
'
  On Error Resume Next
  Set TexttFile = FSO.OpenTextFile(sFileName,1)

'
'  Check for error opening it
'
  If Err.Number &lt;&gt; 0 Then
    ColourNote "white", "red", "Could not open file: " &amp; sFileName 
    ColourNote "white", "red", Err.Description
    On Error GoTo 0 
  Else

    On Error GoTo 0 

'
'  Read contents
'
    Contents = TexttFile.ReadAll
    TexttFile.Close

    Set TexttFile = Nothing

'
'  Split file into lines at carriage return, line feed
'

    LineArray = Split (Contents, vbCrLf)
    Count = 0

'
'  Go through a line at a time
'

    For Each L in LineArray
  
      Count = Count + 1
  
'
'  If found, display it
'

      If InStr (1, L, "%1", vbTextCompare) &gt; 0 Then
        world.Note CStr (Count) &amp; ": " &amp; L
      End If

    Next

    Contents = ""

  End If  ' no error on open

  Set FSO = Nothing
</send>
  </alias>
</aliases>


I wasn't sure what file name you wanted, so you need to put it into a MUSHclient variable "filename".

The alias is just "grep *" so you would type:

grep blue

and it will search the file in the variable "filename". (See the variables configuration screen to add a variable).
#3
Works great, my thanks.