Virtualization Plugins

 View Only
  • 1.  Issue with Bash script

    Posted 08-07-2020 07:48:00 AM
    Edited by Ravi Nistala 08-07-2020 10:36:01 AM
    how to write a for loop in bash script.We have a bashscript with functions inside them. as shown below.

    for sn in "$DBSERVERNAMES"
    do
    ......

    done
    The above works outside fine but when run inside delphix giving the following error.

     /u01/app/toolkit/Delphix_COMMON_e6ae29ec_ab51_2431_7fb5_0b01581f2a9c_informix_host/scripts/bash/linux_x86/bin64/bash: line 75: syntax error near unexpected token `$'do\r''

    Along the same lines can we write functions inside a bash script ?


    thanks
    Ravi.N

    ------------------------------
    Ravi Nistala
    Community Member
    TDGlobal
    ------------------------------


  • 2.  RE: Issue with Bash script
    Best Answer

    Posted 08-10-2020 04:03:00 PM
    Hi Ravi,

    I suspect this is a line-ending issue:
    bash: line 75: syntax error near unexpected token `$'do\r''

    This looks like the bash script has Windows-style line endings (separate carriage-return and line-feed characters), but the remote host's Bash interpreter is expecting Unix-style line endings (a single newline character).

    This can happen if you are using a Windows text editor to create your Bash files. Some editors have settings where you can customize when the editor should use Windows-style and when to use Unix-style (e.g. by extension). If you're using a Windows editor that does NOT have such an option, you'll need to convert the endings using some other method (there are standalone tools, and some source control systems will do this automatically)

    ------------------------------
    Tom Walsh
    Software Engineer
    Delphix
    ------------------------------



  • 3.  RE: Issue with Bash script

    Posted 08-10-2020 11:26:00 PM

    You are absolutely correct . I was able to get over this issue by uunning dos2unix.

     

    Thanks again for your help.