2 Replies - 2145 Views - Last Post: 04 January 2007 - 08:34 AM Rate Topic: -----

#1 max302  Icon User is offline

  • Proud supporter of the lulz
  • member icon

Reputation: 3
  • View blog
  • Posts: 1,281
  • Joined: 05-March 06

Batchscript debugging

Posted 01 January 2007 - 11:14 AM

I had this idea for a little script, and this is my first time try at batch scripting. Here is what I have so far.

@echo off
REM |-----------------------------------------------------|
REM | SSHTorrents										 |
REM | by Maxime Rousseau								  |
REM | http://www.maximerousseau.com/sshtorrents		   |
REM |-----------------------------------------------------|
REM | Requirements as well as usage instructions and tips |
REM | can be found at the url above. To setup, simply	 |
REM | complete the lines below with your SSH login info,  |
REM | and your ready to go.							   |
REM |-----------------------------------------------------|

REM | SSH distant user to be used
set SSHUSER = 'maxime';%SSHUSER%

REM | SSH distand user's password
set SSHPASS = '';%SSHPASS%

REM | SSH server
set SSHHOST = '192.168.0.103';%SSHHOST%

REM | BitTorrent client installed on server
REM | 1 -- BitTorrent official client ||| 2 -- Azureus
set BTCLIENT = '2';%BTCLIENT%

REM | End of user set variables. Don't touch anything beyond this 
REM | point unless you know what you are doing.

REM | Check user input

if %SSHUSER == "" goto nouser
if %SSHPASS == "" goto nopass
if %SSHHOST == "" goto nohost
if !%1==! goto nolink

REM | If everything looks fine, go on to ping host.

set PINGTEST = 
ping %SSHHOST%; %PINGTEST%

if %PINGTEST !==! "0" goto failping

REM | Determine client and command to get passed

if %BTCLIENT == "1" goto btco
if %BTCLIENT == "2" goto btca

:btco
set BTCOMMAND = 'bittorrent-curses';%BTCOMMAND%
goto sendcommand

:btca
set %BTCOMMAND% = 'azureus';%BTCOMMAND%
goto sendcommand

:sendcommand
plink.exe /shh /user %SSHUSER% /pw %SSHPASS% %SSHHOST% "%BTCOMMAND% %1"
goto end

:nouser
echo You did not fill out the user field. 
echo Edit the Script to change it. 
goto end

:nopass
echo You did not fill out the password field.
echo Edit the script to change it. 
goto end

:nohost
echo You did not fill out the host field. 
echo Edit the script to change it.
goto end

:nolink
echo You did not provide any link arguement. 
echo Try dragging and dropping a link on the script.
goto end

:failping
echo The provided host, %SSHHOST%, seems to be down.
echo Check your WAN and LAN connections, firewall settings, ect.
goto end

:end




Everything seems to be working out fine except the ping check part. What I'm trying to do is to ping the given host before sending the ssh command. When I execute, I get:
Ping request could not find host;. Please check the name and try again.
'"0"' is not recognized as an internal or external command,
operable program or batch file.
goto was unexpected at this time.


I assume that it is my attribution of a command to a variable that is not working.

How can I pass on the errorlevel of my ping test to a variable to be checked further down the line?

This post has been edited by max302: 01 January 2007 - 04:07 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Batchscript debugging

#2 max302  Icon User is offline

  • Proud supporter of the lulz
  • member icon

Reputation: 3
  • View blog
  • Posts: 1,281
  • Joined: 05-March 06

Re: Batchscript debugging

Posted 01 January 2007 - 04:18 PM

LOLOLOLOL! I posted my password!!!!
Livin on the edge baby yeah!
Was This Post Helpful? 0
  • +
  • -

#3 max302  Icon User is offline

  • Proud supporter of the lulz
  • member icon

Reputation: 3
  • View blog
  • Posts: 1,281
  • Joined: 05-March 06

Re: Batchscript debugging

Posted 04 January 2007 - 08:34 AM

*Does the bumpy dance*

I can't beleive DIC has no batchscript voodoos.
My syntax and use looks okay I just need some proofing.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1