Bash help needed

Discussion in 'Programming/Scripts' started by TheMuse, Nov 22, 2006.

  1. TheMuse

    TheMuse New Member

    I am a novice running a Linux script with the following code:

    Code:
    #!/bin/sh
    CUR_RUN_NAME='test123'
    RUN_HOME_DIR="/home/Microps/$CUR_RUN_NAME"
    RUN_TMP_DIR="/tmp/$CUR_RUN_NAME"
    echo ${RUN_HOME_DIR}
    mkdir ${RUN_HOME_DIR}
    mkdir ${RUN_TMP_DIR}
    echo "Run Home Directory: $RUN_HOME_DIR"
    cp ${RUN_HOME_DIR}/out1_junk/*.out ${RUN_TMP_DIR}/*.1
    

    The output I get is the following:

    Code:
    /home/Microps/test123
    mkdir: cannot create directory `/home/Microps/test123\r\r\r'
    mkdir: cannot create directory `/tmp/test123\r\r\r'
    Run Home Directory: /home/Microps/test123
    cp: cannot stat `/home/Microps/test123\r\r/out1_junk/*.out': No such file or
    directory
    I was wondering if you had any ideas about how to get rid of the
    Code:
     \r\r\r
    that is being appended at the end or the variable names.
    When I do list the directory using
    it show the directories are created as

    The code :
    Code:
    echo "Run Home Directory: $RUN_HOME_DIR"
    echo "Run Temp Directory: $RUN_TMP_DIR"

    Gives me an output as follows:
    Code:
    Run Home Directory: /home/binoy/Microps/test123
    Run Temp Directory: /tmp/binoy/test123
    There are some hidden characters that are added to my strings which do not show up using the echo command, but show as question marks when i list the directories. How do I ensure that this does not happen?
    It seems to be some kind of a delimiting or "naked" escape character problem, but I am not able to identify it. Any ideas will be greatly appreciated!
    Thanks!!
     
  2. Ben

    Ben Active Member Moderator

    I would try deleting that line with test123, rewrite it and set it into " instead of '
     
  3. falko

    falko Super Moderator Howtoforge Staff

    Also make sure you save that script with Unix linebreaks!
     
  4. TheMuse

    TheMuse New Member

    Thanks

    Thanks Falko!
    It seems like it was using DOS linebreaks even though I had created the file using vi editor!
     
  5. drks

    drks New Member HowtoForge Supporter

    If you or anyone has issues like this you can also use the dos2unix command to fix similar issues... generally when files are created on a windows box and uploaded to a linux box.
     

Share This Page