[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  (Question) Having mushclient do remote tasks and outputting it on screen.

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: (Question) Having mushclient do remote tasks and outputting it on screen.
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Posted by Angelomcm   (7 posts)  [Biography] bio
Date Wed 18 Feb 2004 12:07 PM (UTC)  quote  ]
Message
Works great, my thanks.
[Go to top] top

Posted by Nick Gammon   Australia  (18,800 posts)  [Biography] bio   Forum Administrator
Date Wed 18 Feb 2004 01:04 AM (UTC)  quote  ]
Message
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).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Tue 17 Feb 2004 04:26 PM (UTC)  quote  ]
Message
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 :(

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by Angelomcm   (7 posts)  [Biography] bio
Date Tue 17 Feb 2004 10:59 AM (UTC)  quote  ]
Message
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.
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


1,348 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]