Find the answer to your Linux question:
Results 1 to 5 of 5
Bash refuses to copy my files, I am dumbfounded! #!/bin/bash echo 'Executing for i=1' # executing a script that run a large computation and creates an output file myout, the ...
  1. #1
    Just Joined!
    Join Date
    Jan 2009
    Posts
    4

    Unhappy Schell script would not copy my files

    Bash refuses to copy my files, I am dumbfounded!

    #!/bin/bash

    echo 'Executing for i=1'
    # executing a script that run a large computation and creates an output file myout, the script exe runs fine from the prompt
    exe
    echo "Execution complete"
    cp myout myout.1
    cat myout >> myout.all

    # rerun the script
    echo 'Executing for i=2'
    exe
    echo "Execution complete"
    cp myout myout.2
    cat myout >> myout.all
    ----------

    This script never creates myout.1 nor it redirects myout.1 into myout.all. However, it does create myout.2 correctly and puts its content in myout.all.

    I am very perplexed, please help!

  2. #2
    Linux Guru
    Join Date
    Jan 2009
    Location
    Dover, NH
    Posts
    1,633
    Is the first "exe" a backgrounding task, as in a task that returns the prompt before it's actually done processing?

    I'm thinking that the cp and cat commands are being executed before the myout file has been written, and thus, have nothing to do.

    Try doing something like exe && echo "Execution Complete" on the same line. This way, it should only advance to the echo (and hopefully beyond) after exe has exited with a status of zero (normal termination, operation successful).

    If this doesn't work, you might have to write a more complicated script that wont try to advance until myout is existing and available.

  3. #3
    Just Joined!
    Join Date
    Jan 2009
    Posts
    4
    I tried: exe && echo "Execution complete"
    but no success

  4. #4
    Just Joined!
    Join Date
    Jan 2009
    Posts
    4
    I tried: exe && echo "Execution complete"
    but no success

  5. #5
    Linux Guru
    Join Date
    Jan 2009
    Location
    Dover, NH
    Posts
    1,633
    I'm really good a DOS batch files, and so-so at c programming, but I tend to have to redo shell scripts many times over to make them work the way I want (sorry, I'm just not that good at this beyond the very basics). All I can really do is point you towards a tutorial and hope it helps you out in some way.

    Advanced Bash-Scripting Guide

Posting Permissions

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