0

I am trying to run .sh file on RH6 and getting this error...

cannot open '' for reading: No such file or directory

The script I am running is internally referencing other scripts, located in same directory. I can see them using ls -la.

Note: This script is working perfectly fine on RH4. I got new fresh RH6 machine on which I am trying to run my scripts.

My abc.sh script as mentioned below

. fox_comm_server_details.sh
. fox_comm_topic_names.sh
. fox_comm_sh_tools.sh

refers to other script (.sh) files.

When I run my abc.sh (with ./abc.sh) it says

fox_comm_server_details.sh: cannot open [No such file or directory]

I confirmed the required scripts are present in directory and I have permissions on them. If I update the abc.sh as below...

. ./fox_comm_server_details.sh
. ./fox_comm_topic_names.sh
. ./fox_comm_sh_tools.sh

This time it is not complaining about missing files but some different error as mentioned below...

read_fox_comm_servers_list[134]: read_fox_comm_servers_list_defaults[37]: local: not found [No such file or directory]

read_fox_comm_servers_list and read_fox_comm_servers_list_defaults are functions that are defined in fox_comm_sh_tools.sh as follows...

function read_fox_comm_servers_list
{
        read_fox_comm_servers_list_defaults
        read_fox_comm_servers_list_overrides
}

function read_fox_comm_servers_list_defaults
{
        local tempfile=/tmp/read_fox_comm_servers_list_defaults.$$
}

and getting above mentioned error.

3
  • 3
    Please edit your question to include the script you are trying to run.
    – DavidPostill
    Feb 9, 2015 at 12:34
  • And provide the result of ls -l command. Also did you arr read permission to the script? They can't work w/o this permission Feb 9, 2015 at 12:50
  • What is line 1 of your script. If it's #!/bin/sh, do you know what /bin/sh is on your system (e.g., is it bash or dash)? ... I guess that the 134 and 37 in the error message(s) are line numbers. You're probably right not to dump the entire 135+ line script on us, but have you tried deleting lines from (a working, debug copy of) the script until the error goes away? Try that -- the last thing you deleted will probably be a big clue to the problem. Feb 10, 2015 at 19:49

1 Answer 1

0

A shot in the dark: please edit your question clicking on this link because so it's really difficult to understand.

In general is seems that somewhere in a script (or in a subscript) a variable is not set with a filename.
You can notice from '' without a name inside in your error message

cannot open '' for reading: No such file or directory

You can search where is the error activating the debug in your shell

set -x           # to activate debugging  
./myscript.sh    # here your script invocation  
set +x           # to stop debugging 
1
  • 2
    This won't quite work. Shell options (e.g., xtrace, or -x for short) are not passed from parent to child, so this will only say that the user is running myscript.sh, but not what happens in the script. For that you would need one of the following: (1) set -x; . myscript.sh; set +x (probably not a good idea), (2) (set -x; . myscript.sh) (note the parentheses), (3) sh -x myscript.sh, or (4) edit myscript.sh and append -x to the she-bang line (the #!/bin/sh on the first line). Feb 10, 2015 at 19:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .