Copy Link
Add to Bookmark
Report

NULL mag Issue 08 29 Expect

eZine's profile picture
Published in 
null magazine
 · 3 years ago

  



EXPECT is another shell for linux terminal, than not many people know
about. with it you can write scripts to automate tasks, like
connecting to other machines via ssh/telnet. we could also use it to
automate tasks in our bbs machines, from within the bbs it self.

below is such a script that connects to Another Droid BBS, selects the
ascii theme, cause EXPECT dosn't go well with ansi, logs into the bbs
(i know the theme is fucked up :| ), goes to the message area, selects
the fsxnet group, joins the first area and starts reading the new
messages.

copy/paste it, make it executable and use it like:

./scriptname <username> <password>

EXPECT has some advanced commands, but even with the simple ones,
someone could do cool stuff. if you have the patience you could write
a script that could auto-validate the last user who registered in your
bbs, log in and do a mass upload to the file area or do a globar text
search in the messages area for a specific text (lurker! :) )
you could also use it, out side the bbs, to log in a ssh shell and do
other stuff etc.

if you make something, don't hesitate to share...


'----------------8<-------------[ cut here ]------------------'

#!/usr/bin/expect

#If it all goes pear shaped the script will timeout after 20 seconds.
set timeout 20
#First argument is assigned to the variable name
#Second argument is assigned to the variable user
set user [lindex $argv 0]
#Third argument is assigned to the variable password
set password [lindex $argv 1]
#This spawns the telnet program and connects it to the variable name
spawn telnet andr01d.zapto.org 9999
#The script expects login
#expect "login:"
#The script sends the user variable
#The script expects Password
expect "Choose your theme"
send "2\r"
expect "L O G I N"
send "\r"
expect "Username:"
send "$user\r"
expect "Password:"
#The script sends the password variable
send "$password\r"
expect "login"
send "y"
expect "liners"
send "n"
expect "Command"
send "m"
expect "Command"
send "j"
expect "Group"
sleep 2
send "3"
expect "Command"
send "r"
sleep 1
send "n"
interact

'----------------8<-------------[ cut here ]------------------'


<<< null e-magazine x008 (text edition) >>>
____ _____ _____ _____ http://github.com/xqtr/null
___/. \/ /_________/. /__/. /__jp!_ andr01d.zapto.org:9999
//_ \ . / / \ / _// agency.bbs.nz
/____/\____/ / /__________________\ d1st.org
\________/

← previous
next →
loading
sending ...
New to Neperos ? Sign Up for free
download Neperos App from Google Play
install Neperos as PWA

Let's discover also

Recent Articles

Recent Comments

Neperos cookies
This website uses cookies to store your preferences and improve the service. Cookies authorization will allow me and / or my partners to process personal data such as browsing behaviour.

By pressing OK you agree to the Terms of Service and acknowledge the Privacy Policy

By pressing REJECT you will be able to continue to use Neperos (like read articles or write comments) but some important cookies will not be set. This may affect certain features and functions of the platform.
OK
REJECT