Find the answer to your Linux question:
Results 1 to 2 of 2
Problem Solved... it turn's out the DOS text format was messing things up. wrote the script with emacs, and bingo! Hi. I'm new to linux and scripting, and I'm having ...
  1. #1
    Just Joined!
    Join Date
    Mar 2008
    Posts
    1

    Path Problems - need to run multiple executables from their own directories

    Problem Solved... it turn's out the DOS text format was messing things up. wrote the script with emacs, and bingo!

    Hi. I'm new to linux and scripting, and I'm having trouble with a simple scripting task in cygwin.

    I have a series of directories each with an executable program and text files with variables and parameters. I am trying to write a script that will run each executable file from its own directory, but have not had any success. When I try to run one of the executables from outside its directory, I receive an error that there is "no such file or directory":

    Code:
    $ ./test.sc
    open: No such file or directory
    apparent state: unit 11 named ASTR.INP
    lately writing direct unformatted external IO
    ./test.sc: line 2: $'\r': command not found
    ASTEROID.INP is a text file containing parameters and variables needed to run the executable.
    I'm not sure why I'm getting the $`\r` error (text coding maybe? I used ANSI)

    or course, if i put the script file in the same directory as one of the executables, it works for that one... but I need to run through several directories e.g. /runs/run1, /runs/run2... /runs/run40.

    How can I make the executable look in its own directory for the text files? I'm guessing this should be fairly simple to do, with a bit of know-how(?).

    The data that will be produced is for my masters thesis, and time is getting very short, so if anyone can help, I'd appreciate it very much.
    André
    Last edited by ajdunford; 03-21-2008 at 02:10 AM. Reason: Found the problem

  2. #2
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Quote Originally Posted by ajdunford View Post
    Problem Solved... it turn's out the DOS text format was messing things up. wrote the script with emacs, and bingo!
    In case you want an explanation, I'll hazard the following:

    Your shebang line (indeed all your script's lines) ended with a CR/NL pair; since the NL (\n) is the terminator the shell attempting to be run would have the CR (\r) character appended to its name, so wouldn't be found in the system. Any blank line would yield a CR not found error.

    Glad you solved it for yourself, but you should really be using vi, not emacs.

Posting Permissions

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