NASLite Network Attached Storage

www.serverelements.com
Task-specific simplicity with low hardware requirements.
It is currently Sat Jan 25, 2020 2:11 am

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Tue Sep 18, 2007 1:44 pm 
Offline

Joined: Fri Feb 02, 2007 5:04 pm
Posts: 109
Location: Belgium
Hi guys
Thanks to Georg for his windows shutdownscript
it works like a charme
But I also needed 1 for my Ubuntu box
So I went to town(google actualy) and came up with this:
(mind you, it did take me a couple of sleepless nights, I never made anything like this before)


#!/usr/bin/expect -f

set timeout 15

#------------------------------------------------
#-setting parameters-----------------------------
#------------------------------------------------
set Server "192.168.1.53"
set Login "admin"
set Passw "nas"
set Xit "E"
set Shut "8"
set yes "y"

#------------------------------------------------
#-start telnet-----------------------------------
#------------------------------------------------
spawn telnet $Server

#------------------------------------------------
#-sending username & password--------------------
#------------------------------------------------
expect "server login:"
sleep .5
send -- "$Login\r"
expect "Password:"
sleep .5
send -- "$Passw\r"

#------------------------------------------------
#-shutdown or exit-------------------------------
#-put # for the appropiate line------------------
#------------------------------------------------
expect "Select:"
sleep .5
send -- "$Xit\r"
#send -- "$Shut\r"
expect "Continue: "
sleep .5
send -- "$yes\r"
expect eof

#------------------------------------------------



It's written in expect, so anyone who wants to use it please install expect first
(For me it was available via my Synaptic package manager)

Just copy/paste this in a textfile (from #!/usr/bin/expect -f till the last #---------------- line)
save it somewhere you can remember

you can make a link to that file on your desktop
but Ubuntu kept asking me what I wanted to do with it (execute, execute in a terminal, view, etc) when I ran it
So if you are happy to choose execute in a terminal every time, you're done here
but I wanted to bypass that question,
so I created a new starter on my desktop with the following settings
type: Terminal application
(not completely sure, I got the Dutch version of Ubuntu 7.04 here)
name: something appropiate like "nas shutdown" or so
commandline: the path to your previously saved file
comment: euh whatever you feel like
choose a nice icon and that should be it


I hope it works with you guys just as good as it did here
questions: don't ask me, I just wrote it ;)
I'm not sure I can help anybody with problems being a linux noobie myself

Oh yeah, 1 more thing
just like georg's script, this one is set to exit the telnet session for testing purposes
if you wan to shutdown the server, make these 2 lines
send -- "$Xit\r"
#send -- "$Shut\r"
look like
#send -- "$Xit\r"
send -- "$Shut\r"
stating the obvious probably, but hey not everybody's name is Linus


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group