Redirection output

Hi there

I have a script that runs but it outputs everything onto the screen instead of a file.

I've tried using the > outputfile.txt however all it does is dump the output to the screen and creates an outputfile.txt but doesn't put anything in that file.

Any help would be appreciated

Thanks in advance!

I think it outputs on stderr. Try:

script &> file

Seems to be specific to bash.

If you want to redirect stdout and stderr to the same file :

script >file 2>&1

And if you want separate files :

script >file_for_stdout 2>file_for_stderr

Jean-Pierre.

@kma07: It would be helpful if you can show us the part of the code where you redirect the result of the command to a file.

im not 100% sure as it is not my script and i'm not all that familiar with it but i'll paste some of it:

print STDERR "All done\n\n";

sub rprtProgress {
        my ($skip) = @_;
        $count++;
        if (defined $skip and $skip>1) {
            if ($count % $skip == 1) {
                print STDERR "\n\n" if ($count < $skip);
                my $end = $count + $skip - 1;
                print STDERR "\x1b[1A    reading record $count to $end            \n";
            }
        } else {
            print STDERR "\x1b[1A    reading record $count            \n";
        }
    }
    sub rprtCount {
        print STDERR "Total number of records = $count\n";
    }
}

i've tried doing

./myscript "Public" &> outputfile.txt

and it gives me a Invalid null command... the "Public" is part of the script

---------- Post updated at 08:48 AM ---------- Previous update was at 08:46 AM ----------

and if I try this it tells me:

Ambiguous output redirect

Hi.

Is CSH your default shell?

If so, read this.

(and then this)

Problem solved
Thank you very much everyone!