Computing.Net > Forums > Programming > Escape Command

Escape Command

Reply to Message Icon

Original Message
Name: remgu
Date: December 21, 2007 at 07:24:30 Pacific
Subject: Escape Command
OS: XP
CPU/Ram: P4 3.4Ghz 3GB Ram
Model/Manufacturer: Clone
Comment:

I have a batch file that FTPs data from our servers. I use a menu to have the user decide which server to log into and FTP data from. How can I code it so that at any stage in the prompts, the user can decide to go back to the main menu? This would be useful when they have already chosen a server but then realized that it is the wrong one and they need to choose a different server. Right now they are made to follow the prompts and enter bogus info just to get to the end of the script and have the ability to choose from the menu again. Is there any type of escape command that can be invoked at any time, where I can predetermine where to go when the Escape key is pressed...or something similar to that? Below is sample code of a section where currently the user has to answer the prompts before he can go back to the main menu. Thanks in advance.

:qaLOOP1
Echo Enter the TID (xxxxxx) for the Audit Dump.
Echo.
Set /P dumptid= ^>
Echo.
Echo Enter the Date (yy-mm-dd) for the Audit Dump.
Echo.
Set /P dumpdate= ^>
Echo.
Echo.
Echo The Audit Dump's TID and Date that you entered are %dumptid% and %dumpdate%.
Echo Press Y or y and then ENTER if correct or press ENTER to retry.
Echo.
Set /P answ= ^>
Echo.
Echo.
Echo.
If /I not "%answ%."=="Y." GoTo :qaLOOP1
cd c:\ftp_temp
> latest.ftp.request.txt echo o %qastratusip%
>> latest.ftp.request.txt echo %qastratususername%
>> latest.ftp.request.txt echo %qastratuspassword%
>> latest.ftp.request.txt echo bin
>> latest.ftp.request.txt echo cd audit_dumps
>> latest.ftp.request.txt echo get %dumptid%.%dumpdate%.prt
>> latest.ftp.request.txt echo bye
ftp -s:latest.ftp.request.txt
REM *****************Start of Last FTP Request Time Stamp CODE NOT IN USE***************
REM echo @prompt set date=$d$_set time=$t$h$h$h > {a}.bat
REM %comspec% /e:2048 /c {a}.bat > {b}.bat
REM for %%v in ({b}.bat del) do call %%v {?}.bat
REM echo %date% %time% >> latest.ftp.request.txt
REM *****************End of Last FTP Request Time Stamp*****************

REM *****************Start of code to set date/time variables for filename*****************
@ECHO OFF
FOR /F "TOKENS=2-4 DELIMS=/ " %%a IN ("%date%") DO SET mm=%%a&SET dd=%%b&SET yy=%%c
FOR /F "TOKENS=1-3 DELIMS=:." %%a IN ("%time%") DO SET hh=%%a&SET tt=%%b&SET ss=%%c
REM echo "%yy%-%mm%-%dd% %hh%h.%tt%m.%ss%s"
REM *****************End of code to set date/time variables for filename*****************

REM *****************Start of Delay*****************
ping -n 2 localhost > nul
REM *****************End of Delay*****************

rename %dumptid%.%dumpdate%.prt AuditDump.LK%dumptid%.%dumpdate%_%yy%%mm%%dd%.%hh%%tt%%ss%.txt

REM *****************The next line is to delete the latest.ftp.request.txt file created above******
ECHO Y | DEL latest.ftp.request.txt
Set dumptid=
Set dumpdate=
Set answ=
Pause
goto qamain

Thanks,
REMGU


Report Offensive Message For Removal


Response Number 1
Name: Razor2.3
Date: December 21, 2007 at 19:35:56 Pacific
Reply: (edit)

With any command script, a user can press Ctrl-C, and a prompt will pop up:

Terminate batch job (Y/N)?
Answer Y and be happy.

Report Offensive Follow Up For Removal

Response Number 2
Name: Mechanix2Go
Date: December 22, 2007 at 05:10:11 Pacific
Reply: (edit)

:: ESC from menu

@echo off
setLocal EnableDelayedExpansion

:1
echo After each data point you will be asked to confirm.
echo Press Y or N
echo press Q to quit the sessiion and start over

:2
echo server? && set /p server=
echo server=!server!
choice /n /cqny
goto %errorlevel%

:3
echo ID? && set /p ID=
echo ID=!ID!
choice /n /cqxny
goto %errorlevel%

:4

echo this is 4



=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Escape Command

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes Today.
Discuss in The Lounge