Search code examples
linuxshellshcsh

How to run .out file in csh script?


Is there any way to run .out file by Csh or any other shell script? I want to run those files by one command.

It is okay to change script type, or use any different way. Please tell me the way to run ".out" file.

Code:

#!/bin/csh -f

sh ./update

if($# > 1) then
echo "Too many args."
exit
endif

if($# == 1) then

sh fo.out $1 text
sh fo.out $1 text

endif

./RUN.sh

Error:

fo.out: fo.out: cannot execute binary file
fo.out: fo.out: cannot execute binary file
  1. I want to run "update", "fo.out", "Run.sh" by one command.
  2. If I have don't have an argument, "fo.out" should not be executed.
  3. My OS is Linux.

Solution

  • You don't state the file format of fo.out, but the shell error indicates it's a binary file. Run file fo.out on the command line to confirm what type of file it is, eg:

    $ file fo.out      
    fo.out: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
    

    Assuming it reports an executable file like this one, then you should be able to just run it in your script without the sh interpreter, ie:

    ./fo.out $1 text