Find the answer to your Linux question:
Results 1 to 5 of 5
Hello all, This is my first post in this forum. And I am a complete novice in linux scripting. I have a windows script which runs successfully in win env. ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2009
    Posts
    2

    converting windows script into Linux?


    Hello all,

    This is my first post in this forum. And I am a complete novice in linux scripting.

    I have a windows script which runs successfully in win env. Now I want to run this same script on Linux. If somebody can convert below win script into Linux then it would be great.

    Code:
    echo Start running script
    
    echo  ##### Setting variables #####
    set MY_PATH=/opt/MYDir/bin
    set LOG_HOME=/opt/MYDIR/logs
    
    cmd /c "%MY_PATH%/setVars.sh"
    
    for /f " tokens=1,2,3 delims=/ " %%i in ('date /t') do (
      set dd=%%i
      set mm=%%j
      set YY=%%k
    )
    for /f " tokens=1,2,3 delims=: " %%i in ('time /t') do (
      set xx=%%j
      set hh=%%i
      set zz=%%k
    )
    
    echo Début - %dd%/%mm%/%YY% à %hh%h%xx% > %LOG_HOME%\MY_data.log
    
    echo  ##### Creating FUNCTION please check log at >> %LOG_HOME%\MY_data.log #####
    cmd /c "%MY_PATH%\some-command -c updater.dtd -f my-categories.xml" >> %LOG_HOME%\MY_data.log
    
    echo  ##### Creating Rules please check log at >> %LOG_HOME%\MY_data.log#####
    cmd /c java com.my.company.JavaClass -option1 HELLO -option2 "my-rule.xml" >> %LOG_HOME%\MY_data.log

    Thanks.

    Bye,
    Viki.

  2. #2
    Linux User
    Join Date
    Jun 2007
    Posts
    318
    Sorry but we're not here to do your work. If you run into a specific problem we'll help you. These sites should help:

    Linux/UNIX For DOS Users

    and

    Converting DOS Batch Files to Shell Scripts

  3. #3
    Linux Guru bigtomrodney's Avatar
    Join Date
    Nov 2004
    Location
    Ireland
    Posts
    6,133
    A point of note: DOS Date setting is a pain and quite old fashioned. The date command in Unix is a lot better for specifying what you want and better yet it can be embedded directly into a command.

    DOS
    Code:
    for /f " tokens=1,2,3 delims=: " %%i in ('time /t') do (
      set xx=%%j
      set hh=%%i
      set zz=%%k
    )
    echo Début - %dd%/%mm%/%YY%  > %LOG_HOME%\MY_data.log
    Bash (Unix/Linux)
    Code:
    echo Début\ -\ $(date +%d/%m/%Y) > $LOG_HOME/MY_data.log
    I've trimmed it a bit, it's just to give you a start. The link to the Advanced Bash Scripting guide above is the best place to start. If you understand DOS/NT command scripts you should take to it very quickly. The only problemwill be understanding how much more powerful BASH is compared to DOS!

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Feb 2009
    Posts
    2
    thanks for the help.

  6. #5
    Just Joined! Dingo001's Avatar
    Join Date
    Apr 2008
    Location
    Canada
    Posts
    7

    Passing commands to Linux from MS Bat file

    Hi

    thought I was createting a new post sorry.

Posting Permissions

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