DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: passing a parameter in a batch file

  1. #1
    Join Date
    Oct 2002
    Posts
    182

    passing a parameter in a batch file

    i am creating ftp .cmd and .bat files in order to goto the Unix server and get some files.

    The second directory is Version-specific (ie: build/Build_1_2_3)

    So, I was wondering how to pass a parameter into the command-file in order to goto the correct Build directory. I know how to do this in Unix-shell scripting, but not for Windows command files.

    ie: cd build/$VERSION

    Thanks.
    - Cookies

  2. #2
    Join Date
    Jul 2001
    Location
    Slovenia
    Posts
    422
    cd build\%version%
    Tomaž
    "A common mistake that people make when trying to design something completely
    foolproof is to underestimate the ingenuity of complete fools" - Douglas Adams

  3. #3
    Join Date
    Oct 2002
    Posts
    182
    how do I pass that in?
    Didn't seem to work.

    output:
    Code:
    C:\ftp>start_ftp.bat Build_1_2_3
    
    C:\ftp>echo off
    " starting ftp process"
    ftp> open 192.168.0.71
    Connected to 192.168.0.71.
    220 testweb FTP server (SunOS 5.8) ready.
    User (192.168.0.71:(none)):
    ---> USER wlserver
    331 Password required for wlserver.
    
    ---> PASS password
    230 User wlserver logged in.
    ftp>
    ftp> ascii
    ---> TYPE A
    200 Type set to A.
    ftp> cd /export/wlserver/kaolin/build/%version%
    ---> CWD /export/wlserver/kaolin/build/%version%
    550 /export/wlserver/kaolin/build/%version%: No such file or directory.
    ftp> quit
    ---> QUIT
    221 Goodbye.
    "process complete"

    My files:

    .bat file is:
    Code:
    echo off
    echo " starting ftp process"
    ftp -s:c:\ftp\build_files.cmd %version% -i -d
    echo "process complete"
    echo on
    build_files.cmd is:
    Code:
    open 192.168.0.71
    wlserver
    password
    ascii
    cd /export/wlserver/kaolin/build/%version%
    lcd c:\ftp
    mget masselectric_gw.war
    
    quit
    - Cookies

  4. #4
    Join Date
    Jul 2001
    Location
    Slovenia
    Posts
    422
    Sorry, missunderstood, you cannot pass parameters in ftp.
    But you can dynamically create ftp script in .bat before running ftp like

    Code:
    echo off
    echo " preparing ftp script"
    echo open 192.168.0.71 >c:\ftp\build_files.cmd
    echo wlserver >>c:\ftp\build_files.cmd
    echo password >>c:\ftp\build_files.cmd
    echo ascii >>c:\ftp\build_files.cmd
    echo cd /export/wlserver/kaolin/build/%1 >>c:\ftp\build_files.cmd
    echo lcd c:\ftp >>c:\ftp\build_files.cmd
    echo mget masselectric_gw.war >>c:\ftp\build_files.cmd
    echo quit >>c:\ftp\build_files.cmd
    echo " starting ftp process"
    ftp -s:c:\ftp\build_files.cmd -i -d
    echo "process complete"
    echo on
    Tomaž
    "A common mistake that people make when trying to design something completely
    foolproof is to underestimate the ingenuity of complete fools" - Douglas Adams

  5. #5
    Join Date
    Oct 2002
    Posts
    182
    Thanks.
    That is what I did and it worked just fine.
    Close thread
    - Cookies

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width