Sponsored Content
Top Forums Shell Programming and Scripting Noob Expect Scripting Question Post 302775351 by LongLeafTea on Monday 4th of March 2013 04:23:07 PM
Old 03-04-2013
I have literally nothing as far as this function. This is a chat bot for a hopelessly obscure TTY-based chat system. Right now, it logs in, idles, and responds to specific commands as part of a loop. So far, I haven't had to make any of those responses depend on a particular part of the command. This function will be the instruction to move the bot to another room. If this were IRC, it'd be so much easier. Smilie
Essentially, the bot will see as text in the room "kimiko, go to " (the bot's account name is kimiko), and the word immediately following the space after 'to' will be the room name. I want the script to use "kimiko, go to " as the trigger (expect "kimiko, go to ") and the action to be to capture the following word.

This is part of the main loop. I left some of the functions in so you can see how it operates. The changing room thing basically has me scratching my head completely. I know how to make it look for the trigger phrase. I don't know how to initiate capturing the next word after the trigger phrase.

Code:
while {$Exit != 1 } {
# Temporary simulated commands/responses
expect {
# Greeting, response
    "hai kimiko"    {
        send "\r"
        send "o hai\r"
    }
# Change rooms
    "kimiko, go to"    {
        #Capture the word following 'kimiko, go to ' and store in GoRoom
        send "g" # Initiates room change
        send "$GoRoom\r" #Dumps GoRoom variable into change room command
     }
# Approval of all 'kick' actions against user 'magizian'
    "needs approval to kick magizian"    {
        send "k"
        send "approve\r"
    }
# Exit commandÍ
    "kimiko, you may go now"    {
# Sets Exit variable to 1 to cause loop to exit
        set Exit "1"
        send "\r"
        send "bai\r"
    }
}

# Close brace for end of 'while' loop
}

 

10 More Discussions You Might Find Interesting

1. Programming

Question about compiling (noob)

I'm just getting started to lean C and I'm using Ubuntu today I found a tutorial at this site: http://einstein.drexel.edu/courses/CompPhys/General/C_basics/c_tutorial.html and I got an error after compiling the fist code: #include < stdio.h> void main() { printf("\nHello World\n"); } ... (9 Replies)
Discussion started by: arya6000
9 Replies

2. UNIX for Dummies Questions & Answers

Noob sorting question

Ok here is the deal, I have a command given to me by some systems guy who I cannot get ahold of on the weekend without paying him alot of money to help me. I need to get this done before Monday as I am just getting pummeled by DOS attacks. The comand given was.... netstat -ntu | awk '{print... (1 Reply)
Discussion started by: Hexabah
1 Replies

3. UNIX for Dummies Questions & Answers

Noob question on comparing #'s.

I have a file with 3 digit numbers in it formatted as such: 123 065 321 How would I go about seeing if each number is less than 100 and if so outputting it to another file Yes, I am a bit of a noob. I have tried with grep but I don't think it'll work. Any general direction would be... (6 Replies)
Discussion started by: kirkm76
6 Replies

4. Shell Programming and Scripting

strange expect script behavior, or am i misunderstanding expect scripting?

Hello to all...this is my first post (so please go easy). :) I feel pretty solid at expect scripting, but I'm running into an issue that I'm not able to wrap my head around. I wrote a script that is a little advanced for logging into a remote Linux machine and changing text in a file using sed.... (2 Replies)
Discussion started by: v1k0d3n
2 Replies

5. UNIX for Dummies Questions & Answers

NOOB - Scripting to make an App work

Hello everyone. i work in a school and i ran into an application today that is a real pickle. i know how to make it work, but i would need to script it. The way to make it work would be to have a script check each local user profile on login, see if the directory already exists, do nothing... (27 Replies)
Discussion started by: jscan
27 Replies

6. UNIX for Dummies Questions & Answers

Noob scripting question with android ADB commands

Hi I'm pretty new to scripting and I've been googling around looking for an answer but have yet to come up with a proper solution. I work with multiple android devices at a time and I'm looking to simplify my life with a script. Basically I'm looking for a script that takes the device ID's and then... (2 Replies)
Discussion started by: Onyoursix
2 Replies

7. Shell Programming and Scripting

Noob to Shell Scripting

Hello. I'm attempting to create a shell script to assist me by saving time with one of my hobbies. I am an Android Enthusiast and currently build a few roms for one of the devices. One of the roms I make is ported from a different device to mine (I get the original for the HTC Desire HD and... (3 Replies)
Discussion started by: JHutson456
3 Replies

8. Shell Programming and Scripting

For loop -- noob question

Hello, I am new to shell scripting and i am trying to figure why is this not working with else statement. I am searching for every directory in that DIR i am in, however the "else" seems to be triggered whenever the run the script.. Much thanks in advance! #!/bin/shell for item in... (3 Replies)
Discussion started by: Reb0rn
3 Replies

9. Shell Programming and Scripting

Noob to scripting needs some assistance

Hello, I am in a Unix class and have been out of town. I have been tasked to generate a couple of scripts and ahve never done it before. I have a virtual machine running Ubuntu. The task is below Prompt the system administrator for all valid input parameters Generate a menu to ask which... (1 Reply)
Discussion started by: jkeeton81
1 Replies

10. Shell Programming and Scripting

Total Noob BASH scripting question

Hello All, I have a file of ip addresses called activeips.txt What I'm trying to do is run a simple bash script that has a loop in it. The loop is a cat of the IP addresses in the file. The goal is to run 2 nmap commands to give me outputs where each address in the list has an OS... (11 Replies)
Discussion started by: Dirk_Pitt
11 Replies
JIRC(1p)						User Contributed Perl Documentation						  JIRC(1p)

NAME
jirc - Bridges an IRC channel to a Jabber conference room. SYNOPSIS
jirc [OPTIONS] --config CONFIG -C, --config CONFIG Load config file as specified by CONFIG -V, --version Report version of script -h, --help Show detailed documentation. OPTIONS
-C CONFIG, --config CONFIG Specify the configuration file to load. Required. -V, --version Report the version of this script. -h,--help Show detailed documentation. DESCRIPTION
The jirc bot logs into an IRC channel and a Jabber conference room. It will relay conversations between the two rooms, identifying each of the speakers in braces ([]). Actions are forwarded as well. There are some in-room commands that jirc responds to: !help Display summary of available jirc commands. !who Display a list of people online on the other end of the bridge. !shutdown Immediately quit the rooms and shutdown. CONFIGURATION
The file specified with the --config option contains field/value pairs, one per line: field: value For example: mode: production The required configuration fields are: mode Can be either "production" or "test". When running in "test" mode, the nicks and channel names all have "-test" appended to them so that jirc behavior can be tested in separate channel. irc-nick The IRC nickname to sign in with. Since this is a bridge, a short nick is recommended. To avoid confusion, it should match the jabber-alias. irc-username The IDENT username to sign in with. Since this is a bridge, a short name is recommended. To avoid confusion, it should match the irc-nick. irc-ircname The IRC Username to sign in with. Since this is a bridge, a description of the bridge and a contact email address is recommended. irc-chan The IRC channel to join; the IRC side of the bridge. irc-server The IRC server to join. jabber-protocol The Jabber protocol to use, either "XMPP" or "Legacy". jabber-id The Jabber identifier, in the form: NAME@SERVER/RESOURCE jabber-server-ip Not all Jabber servers run on the same IP as the A record for their domain indicates. If your server runs like this, set the correct IP or hostname here. Note that jirc doesn't currently pay attention to SRV records. jabber-password The password for the Jabber ID. jabber-plaintext Set to "1" to allow the password to be sent over the wire in plaintext or not - you'll need this for some servers that don't support DIGEST-MD5 with legacy authentication. (Default: 0) jabber-reconnect-delay How long to wait in seconds between disconnects before attempting a reconnect. (Default: 0) jabber-port The port to use for Jabber connections. This is normally 5222. jabber-conference The name of the Jabber conference room to join, in the form ROOM@SERVER jabber-alias The Jabber alias to use when joining the Jabber conference room. Since this is a bridge, a short nick is recommend. To avoid confusion, it should match the irc-nick. jabber-admin The email address of this bot's owner. prefix The prefix used for the built-in in-room commands. This is normally "!". quiet-status Suppress bridging of status messages (joins, parts and presence changes). Normally 0. irc-port The port to use for IRC connections. This is normally 6667. irc-reconnect How many seconds to wait until reconnecting after a missed IRC "TIME" response. This is normally 60. irc-time-delay How many seconds between "TIME" requests. This is normally 30. irc-debug When set to 1, this enables verbose debugging of the IRC side of communications. This is normally 0. jabber-debug When set to 1, this enables verbose debugging of the Jabber side of communications. This is normally 0. debug When set to 1, this enable verbose debugging of the general operation of the jirc bridge. This is normally 0. AUTHOR
Kees Cook <kees@outflux.net> COPYRIGHT
Copyright 2005-2009 by Kees Cook <kees@outflux.net>. This program is licensed under the terms of the GNU General Public License. perl v5.10.1 2009-10-26 JIRC(1p)
All times are GMT -4. The time now is 08:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy