Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: create a batch file on this situation  (Read 2157 times)

0 Members and 1 Guest are viewing this topic.

afortaliza

  • Guest
create a batch file on this situation
« on: November 19, 2007, 05:57:31 AM »
Create a .bat file on Windows and a .sh file on Unix that does the following

- takes one argument,
- if the argument = 1, then display the message "this is the first argument"
- if the argument = 2, then display the time of day
- if the argument = "last", then run another script that effectively counts from 1 to 10 using a FOR loop

this is my script, but it is not working. The argument last, i dont how to create script on this also that counts 1 to 10, please help


@ECHO off
cls

:start
ECHO.
ECHO 1. Display this is the first argument
ECHO 2. Display the time of day
ECHO last. Run other script
set choice=
set /p choice=Type the argument to print the output.
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto argument
if '%choice%'=='2' goto time_day
if '%choice%'=="last" goto run_script
ECHO "%choice%" is not valid please try again
ECHO.
goto start
:argument
ECHO this is the first argument
goto end

:time_day
ECHO |TIME|
goto end

:run_script
CALL C:\WINDOWS\NEW_BATCHFILE.BAT
goto end
:end



please help


Anodoin



    Intermediate

    Re: create a batch file on this situation
    « Reply #1 on: November 19, 2007, 06:10:50 PM »
    Quick and ugly:

    set n=1

    :Start
    echo %n%
    if %n%==10 goto Done
    if %n%==9 set n=10
    if %n%==8 set n=9
    if %n%==7 set n=8
    if %n%==6 set n=7
    if %n%==5 set n=6
    if %n%==4 set n=5
    if %n%==3 set n=4
    if %n%==2 set n=3
    if %n%==1 set n=2
    goto Start

    :Done