Batchscript debugging

liunx

Guest
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. <br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->@echo off<br />REM |-----------------------------------------------------|<br />REM | SSHTorrents                                         |<br />REM | by Maxime Rousseau                                  |<br />REM | http://www.maximerousseau.com/sshtorrents           |<br />REM |-----------------------------------------------------|<br />REM | Requirements as well as usage instructions and tips |<br />REM | can be found at the url above. To setup, simply     |<br />REM | complete the lines below with your SSH login info,  |<br />REM | and your ready to go.                               |<br />REM |-----------------------------------------------------|<br /><br />REM | SSH distant user to be used<br />set SSHUSER = 'maxime';%SSHUSER%<br /><br />REM | SSH distand user's password<br />set SSHPASS = '';%SSHPASS%<br /><br />REM | SSH server<br />set SSHHOST = '192.168.0.103';%SSHHOST%<br /><br />REM | BitTorrent client installed on server<br />REM | 1 -- BitTorrent official client ||| 2 -- Azureus<br />set BTCLIENT = '2';%BTCLIENT%<br /><br />REM | End of user set variables. Don't touch anything beyond this <br />REM | point unless you know what you are doing.<br /><br />REM | Check user input<br /><br />if %SSHUSER == "" goto nouser<br />if %SSHPASS == "" goto nopass<br />if %SSHHOST == "" goto nohost<br />if !%1==! goto nolink<br /><br />REM | If everything looks fine, go on to ping host.<br /><br />set PINGTEST = <br />ping %SSHHOST%; %PINGTEST%<br /><br />if %PINGTEST !==! "0" goto failping<br /><br />REM | Determine client and command to get passed<br /><br />if %BTCLIENT == "1" goto btco<br />if %BTCLIENT == "2" goto btca<br /><br />:btco<br />set BTCOMMAND = 'bittorrent-curses';%BTCOMMAND%<br />goto sendcommand<br /><br />:btca<br />set %BTCOMMAND% = 'azureus';%BTCOMMAND%<br />goto sendcommand<br /><br />:sendcommand<br />plink.exe /shh /user %SSHUSER% /pw %SSHPASS% %SSHHOST% "%BTCOMMAND% %1"<br />goto end<br /><br />:nouser<br />echo You did not fill out the user field. <br />echo Edit the Script to change it. <br />goto end<br /><br />:nopass<br />echo You did not fill out the password field.<br />echo Edit the script to change it. <br />goto end<br /><br />:nohost<br />echo You did not fill out the host field. <br />echo Edit the script to change it.<br />goto end<br /><br />:nolink<br />echo You did not provide any link arguement. <br />echo Try dragging and dropping a link on the script.<br />goto end<br /><br />:failping<br />echo The provided host, %SSHHOST%, seems to be down.<br />echo Check your WAN and LAN connections, firewall settings, ect.<br />goto end<br /><br />:end<br /><br /><!--c2--></div><!--ec2--><br /><br />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:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><br />Ping request could not find host;. Please check the name and try again.<br />'"0"' is not recognized as an internal or external command,<br />operable program or batch file.<br />goto was unexpected at this time.<!--c2--></div><!--ec2--><br /><br />I assume that it is my attribution of a command to a variable that is not working. <br /><br />How can I pass on the errorlevel of my ping test to a variable to be checked further down the line?<br /><br /><span class='edit'>This post has been edited by <b>max302</b>: 1 Jan, 2007 - 04:07 PM</span>
</div>
 
Back
Top