Solved

Help with batch script user prompt

Posted on 2008-06-25
1
1,008 Views
Last Modified: 2012-05-05
I have a script below that I'm trying to give the user options on what actions to perform. My syntax is wrong and was hoping for some help. I got a couple problems with my script that I don't know how to fix:

1.) How do I make a multiple line prompt? All my "echos" with the number legends aren't printing under the question.

2.) One of my options is to run ALL actions, but how do I run every subroutine if the user entered "1"?

I would greatly appreciate any help or suggestions.
@ECHO OFF
SETLOCAL
 
rem ------------------------------------------------
rem --------------- GLOBAL VARIABLES ---------------
rem ------------------------------------------------
SET SCRIPTPATH=C:\websites\tools
 
SET /P ACTION=Which action would you like to perform?
ECHO ALL Operations Below .............................. 1
ECHO MIRROR Development to Backup FTP .................. 2
ECHO MIRROR Development to Stable  ..................... 3
ECHO MIRROR Stable to Local Live Website ............... 4
ECHO MIRROR Stable to Remote Live Website .............. 5
ECHO MIRROR Local Sub-Sites to Development ............. 6
ECHO SYNC Local and Remote Sub-Sites ................... 7
 
IF /I "%ACTION%"=="1" GOTO 
IF /I "%ACTION%"=="2" GOTO DevToFTP
IF /I "%ACTION%"=="3" GOTO DevToStable
IF /I "%ACTION%"=="4" GOTO StableToLive
IF /I "%ACTION%"=="5" GOTO StableToRemote
IF /I "%ACTION%"=="6" GOTO SitesToDev
IF /I "%ACTION%"=="7" GOTO SyncLiveRemote
GOTO:EOF
 
rem ------------------------------------------------
rem ------- MIRROR DEV TO REMOTE BACKUP FTP --------
rem ------------------------------------------------
:DevToFTP
rem CALL %SCRIPTPATH%\FTPSync\DevToFTP.cmd
GOTO:EOF
 
rem ------------------------------------------------
rem ---------- MIRROR DEVELOPMENT TO STABLE --------
rem ------------------------------------------------
:DevToStable
rem CALL %SCRIPTPATH%\FileSync\DevToStable.cmd
GOTO:EOF
 
rem ------------------------------------------------
rem ---------- MIRROR STABLE TO LOCAL LIVE ---------
rem ------------------------------------------------
:StableToLive
rem CALL %SCRIPTPATH%\FileSync\StableToLive.cmd
GOTO:EOF
 
rem ------------------------------------------------
rem ---------- MIRROR STABLE TO REMOTE LIVE --------
rem ------------------------------------------------
:StableToRemote
rem CALL %SCRIPTPATH%\FTPSync\StableToRemote.cmd
GOTO:EOF
 
rem ------------------------------------------------
rem ----------- SYNC LOCAL AND REMOTE SITES --------
rem ------------------------------------------------
:SyncLiveRemote
rem CALL %SCRIPTPATH%\FTPSync\SyncLiveRemote.cmd
GOTO:EOF
 
 
rem ------------------------------------------------
rem -------------- MIRROR SITES TO DEV -------------
rem ------------------------------------------------
:SitesToDev
rem CALL %SCRIPTPATH%\FileSync\SitesToDev.cmd
GOTO:EOF

Open in new window

0
Comment
Question by:bemara57
1 Comment
 
LVL 2

Accepted Solution

by:
thefaza earned 500 total points
ID: 21872293
This should work:
@ECHO OFF
SETLOCAL
 
rem ------------------------------------------------
rem --------------- GLOBAL VARIABLES ---------------
rem ------------------------------------------------
SET SCRIPTPATH=C:\websites\tools
 
 
ECHO ALL Operations Below .............................. 1
ECHO MIRROR Development to Backup FTP .................. 2
ECHO MIRROR Development to Stable  ..................... 3
ECHO MIRROR Stable to Local Live Website ............... 4
ECHO MIRROR Stable to Remote Live Website .............. 5
ECHO MIRROR Local Sub-Sites to Development ............. 6
ECHO SYNC Local and Remote Sub-Sites ................... 7
SET /P ACTION=Which action would you like to perform?
 
IF /I "%ACTION%"=="1" GOTO DevToFTP
IF /I "%ACTION%"=="2" GOTO DevToFTP
IF /I "%ACTION%"=="3" GOTO DevToStable
IF /I "%ACTION%"=="4" GOTO StableToLive
IF /I "%ACTION%"=="5" GOTO StableToRemote
IF /I "%ACTION%"=="6" GOTO SitesToDev
IF /I "%ACTION%"=="7" GOTO SyncLiveRemote
GOTO:EOF
 
rem ------------------------------------------------
rem ------- MIRROR DEV TO REMOTE BACKUP FTP --------
rem ------------------------------------------------
:DevToFTP
rem CALL %SCRIPTPATH%\FTPSync\DevToFTP.cmd
IF /I "%ACTION%"=="1" GOTO DevToStable
GOTO:EOF
 
rem ------------------------------------------------
rem ---------- MIRROR DEVELOPMENT TO STABLE --------
rem ------------------------------------------------
:DevToStable
rem CALL %SCRIPTPATH%\FileSync\DevToStable.cmd
IF /I "%ACTION%"=="1" GOTO StableToLive
GOTO:EOF
 
rem ------------------------------------------------
rem ---------- MIRROR STABLE TO LOCAL LIVE ---------
rem ------------------------------------------------
:StableToLive
rem CALL %SCRIPTPATH%\FileSync\StableToLive.cmd
IF /I "%ACTION%"=="1" GOTO StableToRemote
GOTO:EOF
 
rem ------------------------------------------------
rem ---------- MIRROR STABLE TO REMOTE LIVE --------
rem ------------------------------------------------
:StableToRemote
rem CALL %SCRIPTPATH%\FTPSync\StableToRemote.cmd
IF /I "%ACTION%"=="1" GOTO SitesToDev
GOTO:EOF
 
rem ------------------------------------------------
rem ----------- SYNC LOCAL AND REMOTE SITES --------
rem ------------------------------------------------
:SyncLiveRemote
rem CALL %SCRIPTPATH%\FTPSync\SyncLiveRemote.cmd
GOTO:EOF
 
 
rem ------------------------------------------------
rem -------------- MIRROR SITES TO DEV -------------
rem ------------------------------------------------
:SitesToDev
rem CALL %SCRIPTPATH%\FileSync\SitesToDev.cmd
IF /I "%ACTION%"=="1" GOTO SyncLiveRemote
GOTO:EOF

Open in new window

0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question