Home > database >  Run a batch file using "Batch" command
Run a batch file using "Batch" command

Time:03-21

I am currently working on a project in which the deliverable is a .sh file. When I run the file using ./file.sh it works just fine. But according to the prof. we have to run the file using this statement. Batch file.sh. This does not work, and the errors returned are batch accepts no parameters. Which makes sense after reading the man page.

What is the proper way to use the batch command? Is it even possible to run it the way that the professor wants?

CodePudding user response:

According to your description, the file you are trying to execute shouldn't be executed with Batch but Bash/Shell.

Following Batch file, Batch is not supposed to run programs with the sh extension (sh stands for shell).

You can validate what interpreter the program you are trying to use should be run with with the following ways:

  1. Checking the shebang
  2. Using the file command (i.e. file ./your_program.sh)

After finding the correct interpreter, you can run the program with calling it (i.e. sh ./your_program.sh)

  • Related