Script works but misses an option:-)

Microsoft Windows xp pro with sp3 multil...
September 3, 2009 at 09:14:38
Specs: Windows XP
Hi guys,

I've made a rather badly programmed script, but hey, it works:).

When I execute the plink executable it creates a tunnel. When successful it does not inform the user because the next command will not be executed until the tunnel is closed.

I'd like to display a message: Connection established! or something similar. Is this possible?

Any help is much appreciated,

Jeroen

Ps: this is the script:
@echo off
REM default port variable
set default_port=443
REM hostname of your router
set hostname=DDWRT

:retry
echo Please select a port number from following list:
echo.
echo 1: 23
echo 2: 25
echo 3: 53
echo 4: 80
echo 5: default port (HTTPS - 443)
echo 0: press the number 0 to abort and exit
set/p port=Input [1-5]:


if %port%==0 exit
if %port% gtr 5 goto error
if %port% lss 0 goto error
if %port%==5 goto default
if %port%==1 goto custom
if %port%==2 goto custom
if %port%==3 goto custom
if %port%==4 goto custom


:default
echo.......................................................................
echo You have selected a correct port number .
echo Trying to establish tunnel to port %default_port% on host %hostname% .
echo.......................................................................
plink.exe -N -P %default_port% -D 8080 root@xxxxxxxx > Nul: 2>&1
IF %ERRORLEVEL% NEQ 0 goto failed
pause
exit

:custom
if %port%==1 set port=23
if %port%==2 set port=25
if %port%==3 set port=53
if %port%==4 set port=80
echo...............................................................
echo.You have selected a correct port number. .
echo.Trying to establish tunnel to port %port% on host %hostname% .
echo...............................................................
plink.exe -N -P %port% -D 8080 root@xxxxxxxx> Nul: 2>&1

IF %ERRORLEVEL% NEQ 0 goto failed

pause
echo.
exit


:error
echo.
echo.Invalid choice entered. Please try again.
goto retry

:failed
echo.
echo.
echo.Unable to create the tunnel. Please try again with a different port number.
goto retry


See More: Script works but misses an option:-)

Report •


#1
September 4, 2009 at 06:51:20
If you had some way to test the plink connection, it should be possible with a second script and start /b

Report •

#2
September 6, 2009 at 23:29:13
Thanks, I might try that. It's pretty confusing having to guess whether the tunnel is up.

regards,

Jeroen


Report •

Related Solutions


Ask Question