• December 15, 2019, 07:40:21 AM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

This Forum Beta is ONLY for registered owners of D-Link products in the USA for which we have created boards at this time.

Author Topic: Shutdown script - provided here ...  (Read 24365 times)

AndyB

  • Level 1 Member
  • *
  • Posts: 14
Shutdown script - provided here ...
« on: September 30, 2009, 04:44:09 AM »

Hi,

I assume that I'm not the only one having this problem:

More then DNS-323 and just one UPS (with USB Signalling) so - only the NAS attached to the UPS via USB will shutdown automatically.

I created a simple shutdown script for windows.
It allows you to shutdown the NAS via wget (windows build) and 2 http calls.

Wget (all in one binary - no libraries needed)
Download for Win32: http://users.ugent.be/~bpuype/wget/
thanks to Bart Puype for the wget build ;-)

When the main server shuts down due to a UPS Command, the script is called by the UPS Software during shutdown.

Cheers,
AndyB

Just copy the following lines to notepad and save as nas_shutdown.bat

Code: [Select]
@echo off
rem --- D-Link DNS-323 Shutdown Script
rem --- created by Andreas Baumgärtner
rem --- version 1.0
rem --- 20090930

rem --- Info:
rem --- don't change the uname!!
rem --- change passwd and ip to your needs
rem --- timeout is in seconds adjust it to your needs - for me 5 seconds where enough
rem --- only one try otherwise the script could delay the shutdown for too long
 
echo Shutting down NAS_002 ...
set UNAME=admin
set PASSWD=yourpassword
set IP=172.17.0.6
wget  --tries=1 --timeout=5 "http://%IP%/goform/formLogin?f_login_type=0&f_LOGIN_NAME=%UNAME%&f_LOGIN_PASSWD=%PASSWD%"
IF %ERRORLEVEL%==0 (
wget --tries=1 --timeout=5 "http://%IP%/goform/sysShutDown?shootdown"
) ELSE (
echo Unable to shutdown NAS_002
)

echo Shutting down NAS_001 ...
set UNAME=admin
set PASSWD=yourpassword2
set IP=172.17.0.5
wget  --tries=1 --timeout=5 "http://%IP%/goform/formLogin?f_login_type=0&f_LOGIN_NAME=%UNAME%&f_LOGIN_PASSWD=%PASSWD%"
IF %ERRORLEVEL%==0 (
wget --tries=1 --timeout=5 "http://%IP%/goform/sysShutDown?shootdown"
) ELSE (
echo Unable to shutdown NAS_001
)

SET IP=
SET PASSWD=
SET UNAME=
Logged

hilaireg

  • Level 3 Member
  • ***
  • Posts: 333
Re: Shutdown script - provided here ...
« Reply #1 on: September 30, 2009, 05:51:09 AM »

If there was a usefulness rating on threads in this forum and 10 = Absolutely Amazing ...

I'd give this thread a 8.99.

... I never give out 9's & 10's  ;)


Nicely done,

 :)
« Last Edit: September 30, 2009, 05:07:24 PM by hilaireg »
Logged

rsbrace

  • Level 1 Member
  • *
  • Posts: 7
Re: Shutdown script - provided here ...
« Reply #2 on: September 30, 2009, 03:32:39 PM »

Nice, I'm going to give it a try tonight.
Logged

ECF

  • Poweruser
  • Level 11 Member
  • *
  • Posts: 2692
Re: Shutdown script - provided here ...
« Reply #3 on: October 02, 2009, 02:35:34 PM »

Sweet!!
Logged
Never forget that only dead fish swim with the stream

luckyboy

  • Level 1 Member
  • *
  • Posts: 6
Re: Shutdown script - provided here ...
« Reply #4 on: October 05, 2009, 11:35:35 AM »

Fantastic! That's exactly what I'm looking for...
Thank you for this AndyB!
Logged

Giammi_1963

  • Level 1 Member
  • *
  • Posts: 13
Re: Shutdown script - provided here ...
« Reply #5 on: December 06, 2009, 02:53:56 PM »

Hi,
thank a lot for your suggestion; I'm in a different situation, I have only one DNS-323 and not plugged on the UPS. I tried this script but it doesn't works, even if I put off the line from ") else (" and I changed the name of the NAS (rigth name is NASCasa).
Any suggestions ?
Thanks a lot in advance
Gianni
Logged

Giammi_1963

  • Level 1 Member
  • *
  • Posts: 13
Re: Shutdown script - provided here ...
« Reply #6 on: December 10, 2009, 02:01:26 AM »

Hi,
thank a lot for your suggestion; I'm in a different situation, I have only one DNS-323 and not plugged on the UPS. I tried this script but it doesn't works, even if I put off the line from ") else (" and I changed the name of the NAS (rigth name is NASCasa).
Any suggestions ?
Thanks a lot in advance
Gianni

...any comment ?
Logged

AndyB

  • Level 1 Member
  • *
  • Posts: 14
Re: Shutdown script - provided here ...
« Reply #7 on: December 10, 2009, 03:41:02 AM »

Hi Gianni,
I sent you an email offline on monday - no reply so far from you ...

Just to be very clear - the script will work with DNS-323 with our without UPS connection. I created the script out of this usecase ...

Requirements:
you need wget downloaded and working (in same directory as the script or in the path).
the name of the nas is irrelevant. you only need to alter 2 lines in the script:

set PASSWD=yourpassword    <--- put your password here (attention to spaces)
set IP=172.17.0.6                 <--- put the IP of the NAS you want to shutdown here

Some additional questions:
DNS-323 Firmware?
What OS are you using?

Cheers,
Andi
Logged

MichelR

  • Level 1 Member
  • *
  • Posts: 1
Re: Shutdown script - provided here ...
« Reply #8 on: June 21, 2010, 05:25:24 AM »

Thanks for this, this is exactly what I had been looking for.

Sorry for revive a 6+ month old thread, but when I tried this it didn't work at first, and the reason was simple: I was logged in through the web interface to the DNS-323.  The output from the script did not indicate any error that I could see though  I did find it weird that there was no delay at all when it was trying to log in.

After I logged off from the web interface, the script successfully shut down the DNS-323.  Just thought this little bit of information could be useful to some people. :)
Logged

infecticide

  • Level 1 Member
  • *
  • Posts: 1
Re: Shutdown script - provided here ...
« Reply #9 on: November 29, 2013, 12:35:35 PM »

I tried this script but it doesn't work for me:

Firmware - 1.10
FFP_VERSION=0.7.1
FFP_ARCH=oarm

Is there a newer one out, or another way to accomplish this?
Logged

hercules71035

  • Level 1 Member
  • *
  • Posts: 12
Re: Shutdown script - provided here ...
« Reply #10 on: March 02, 2015, 02:33:49 AM »

Hi there,
I'm looking for use your script on Linux machine (raspberry with raspbian), so I tried to convert your script, but I have a problem with variable ERRORLEVEL. My script is:
Code: [Select]
#/bin/bash
echo D-Link DNS-323 Shutdown Script
echo created by Andreas Baumgärtner
echo version 1.0
echo 20090930

#Info:
#don't change the uname!!
#change passwd and ip to your needs
#timeout is in seconds adjust it to your needs - for me 5 seconds where enough
#only one try otherwise the script could delay the shutdown for too long
 
echo Shutting down NAS ...
UNAME=admin
PASSWD=yourpassword
IP=172.17.0.6
wget  --tries=1 --timeout=5 "http://$IP/goform/formLogin?f_login_type=0&f_LOGIN_NAME=$UNAME&f_LOGIN_PASSWD=$PASSWD"
IF $ERRORLEVEL==0 (
wget --tries=1 --timeout=5 "http://$IP/goform/sysShutDown?shootdown"
) ELSE (
echo Unable to shutdown NAS
)

Anyone can help me on converting this script?
It works fine untile the ERRORLEVEL variable.

Thanks.
Logged

Ctopia

  • Level 1 Member
  • *
  • Posts: 5
Re: Shutdown script - provided here ...
« Reply #11 on: April 26, 2015, 07:18:34 AM »

Hi,

I might be able to use this with DNR 322L, but wget is not available from the link anymore.

Quote
wget not available: http://users.ugent.be/~bpuype/wget/
can I have a copy again, anybody?

Once I got, wget, where do I place it?
and Also where do I place the Script?

Thanks..

Hi,

I assume that I'm not the only one having this problem:

More then DNS-323 and just one UPS (with USB Signalling) so - only the NAS attached to the UPS via USB will shutdown automatically.

I created a simple shutdown script for windows.
It allows you to shutdown the NAS via wget (windows build) and 2 http calls.

Wget (all in one binary - no libraries needed)
Download for Win32: http://users.ugent.be/~bpuype/wget/
thanks to Bart Puype for the wget build ;-)

When the main server shuts down due to a UPS Command, the script is called by the UPS Software during shutdown.

Cheers,
AndyB

Just copy the following lines to notepad and save as nas_shutdown.bat

Code: [Select]
@echo off
rem --- D-Link DNS-323 Shutdown Script
rem --- created by Andreas Baumgärtner
rem --- version 1.0
rem --- 20090930

rem --- Info:
rem --- don't change the uname!!
rem --- change passwd and ip to your needs
rem --- timeout is in seconds adjust it to your needs - for me 5 seconds where enough
rem --- only one try otherwise the script could delay the shutdown for too long
 
echo Shutting down NAS_002 ...
set UNAME=admin
set PASSWD=yourpassword
set IP=172.17.0.6
wget  --tries=1 --timeout=5 "http://%IP%/goform/formLogin?f_login_type=0&f_LOGIN_NAME=%UNAME%&f_LOGIN_PASSWD=%PASSWD%"
IF %ERRORLEVEL%==0 (
wget --tries=1 --timeout=5 "http://%IP%/goform/sysShutDown?shootdown"
) ELSE (
echo Unable to shutdown NAS_002
)

echo Shutting down NAS_001 ...
set UNAME=admin
set PASSWD=yourpassword2
set IP=172.17.0.5
wget  --tries=1 --timeout=5 "http://%IP%/goform/formLogin?f_login_type=0&f_LOGIN_NAME=%UNAME%&f_LOGIN_PASSWD=%PASSWD%"
IF %ERRORLEVEL%==0 (
wget --tries=1 --timeout=5 "http://%IP%/goform/sysShutDown?shootdown"
) ELSE (
echo Unable to shutdown NAS_001
)

SET IP=
SET PASSWD=
SET UNAME=
« Last Edit: April 26, 2015, 07:39:08 AM by Ctopia »
Logged

simgambu

  • Level 1 Member
  • *
  • Posts: 1
Re: Shutdown script - provided here ...
« Reply #12 on: January 31, 2016, 08:33:59 AM »

Linux script:

Code: [Select]
#!/bin/sh
#
# --- D-Link DNS-323 Shutdown Script
# --- created by Andreas Baumgärtner
# --- version 1.0
# --- 20090930
#
# --- Info:
# --- don't change the uname!!
# --- change passwd and ip to your needs
# --- timeout is in seconds adjust it to your needs - for me 5 seconds where enough
# --- only one try otherwise the script could delay the shutdown for too long
 
echo Shutting down DS-323 ...

UNAME=admin
PASSWD=password
IP=172.10.34.223

echo "http://$IP/goform/formLogin?f_login_type=0&f_LOGIN_NAME=$UNAME&f_LOGIN_PASSWD=$PASSWD"
wget  --tries=1 --timeout=5 "http://$IP/goform/formLogin?f_login_type=0&f_LOGIN_NAME=$UNAME&f_LOGIN_PASSWD=$PASSWD"
if [ $? -eq 0 ]
 then
    echo "http://$IP/goform/sysShutDown?shutdown"
    wget --tries=1 --timeout=5 "http://$IP/goform/sysShutDown?shutdown"
 else
    echo Unable to shutdown NAS_002
 fi

IP=
PASSWD=
UNAME=
Logged

la72pt

  • Level 1 Member
  • *
  • Posts: 3
Re: Shutdown script - provided here ...
« Reply #13 on: July 05, 2016, 12:04:34 PM »

hi,
there are any possibility to adapt this script to dns320l?
i tried without success.
allways get error in 'wget' login.

"
Connecting to 192.168.1.99:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2016-07-05 19:58:00 ERROR 404: Not Found.

errorlevel="8"
"

thank you.
Logged