command not found error while executing a shell script
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
drop index sales_time_bix;
drop index sales_time_idx;
create index sales_time_idx on sales(time_id) compute statistics;
-----------------------------------------------------------------
-- fetch_n_rows: fetches 'n' rows from the specified statement --
-----------------------------------------------------------------
CREATE OR REPLACE PROCEDURE fetch_n_rows(
stmt VARCHAR,
name VARCHAR,
nexec NUMBER := 1,
nrows NUMBER := 0,
debug BOOLEAN := FALSE)
IS
-- Local variables
curs INTEGER := null;
rc INTEGER;
nexec_it INTEGER := 0;
nrows_it INTEGER;
BEGIN
LOOP
IF (dbms_sql.fetch_rows(curs) <= 0 OR (nrows <> 0 AND nrows_it = nrows
))
THEN
EXIT;
ELSE IF (debug = TRUE)
THEN
DBMS_OUTPUT.PUT_LINE(nrows_it);
END IF;
END IF;
Edit your profile to include the specific Linux distribution(s) you are using.
Post the command you issued and all that bash spit out.
Using command: ls -l start_workload.sh, bash will tell you who is capable of executing the script. Below is an example of the script if it was executable by all:
Quote:
-rwxrwxrwx 1 me me 896 May 3 13:23 start_workload.sh
The (x)s represent executable. If you as a user (the second set of rwx) do not have the x, you cannot run the script as a user, run it as superuser/root or sudo, or change permissions of the script so a user can run it with command as superuser/root or sudo: chmod 777 start_workload.sh. After changing the permissions as outlined it should look like the example I posted with three sets of rwx and anybody can run the script.
grant connect, resource, dba to SH;
alter user sh account unlock;
The lines in the setup_perlab.sh script quoted above are the current problem. Bash does not recognize those two commands. Was this script designed for Linux or some other Unix based operating system like Mac OS X or something?
You may need to provide more information regarding the script, such as the software suite you are trying to configure. Many script errors are a result of out-dated software not configured to work with the latest Linux kernel. But this error relates to un-recognized commands in the script.
After changing permissions of a file, just do the: ls -l start_workload.sh again to see what happened.
EDIT: Often, bash will give the "command not found" error when a script is designed to be run as root and you are running it as a user.
The very first statement in the script cd $HOME/wkdir generates and error
no such file or directory cd: /home/oracle/wkdir. Although, when i type
cd $HOME/wkdir at the prompt.It works just fine. It is just when i put them in script it gives me error.
Brains, I don't think we know for sure that SurbhiJain is running this from a bash shell. There is no "hash bang" forcing execution by bash.
It looks as if the shell is not recognizing the "here document" inline redirection (the <<!) in the command "sqlplus "/ as sysdba" <<! > /tmp/perflab_install.log 2>&1" (Although the "2>&1" seems to imply bash.)
It's also very suspicious that the shell executing the script does not know the value of the $HOME environmental variable (cd $HOME/wkdir generates and error). Maybe something funky with sudoers?
I did a little experiment on my system, and both bash and ksh support "!" as the here document delimiter.
Code:
[root@athlonz ~]# cat zzz
DATE=`date`
HOST=`uname -n`
cat <<!
Something went horribly wrong with system $HOST
at $DATE
btw, your HOME environmental variable is $HOME
!
[root@athlonz ~]# bash zzz
Something went horribly wrong with system athlonz.tomlovell.com
at Sun Jul 25 18:41:24 EDT 2010
btw, your HOME environmental variable is /root
[root@athlonz ~]# ksh zzz
Something went horribly wrong with system athlonz.tomlovell.com
at Sun Jul 25 18:41:30 EDT 2010
btw, your HOME environmental variable is /root
[root@athlonz ~]# echo $HOME
/root
[root@athlonz ~]#
It looks as if the shell executing your script does not support <<! for some reason.
Can you tell us what shell you are using. The SHELL environmental variable usually contains the current shell.
Do an 'echo $SHELL' and let us know the output.
Also, how are you executing 'start_workload.sh'? Just typing it on the command line?
If you are using bash, 'bash --version' will tell the version. Maybe it's an bug in bash.
Last edited by tommylovell; 07-25-2010 at 06:12 PM.
I am attaching one file giving the answers of your questions. I am sorry i did not tell the name of the script..it is setup_perflab.sh . $HOME variable points to /home/oracle .
I don't think we know for sure that SurbhiJain is running this from a bash shell
This is one of the many reasons it helps to know which Linux distribution the OP is using (Put it in the profile), which would make it easier for those that want to help, make better assumptions.
Aha. I think the the giveaway here is the "rm: cannot remove '/tmp/*.log\r': no such file or directory".
I don't think you have legitimate lineend characters in your script file, as evidenced by the '\r' in that error message. This sometimes happens when the file comes from another (usually inferior) operating system.
Type "hexdump -C setup_perflab.sh". It will show you the return character on each line of text. Each line should be immediately followed by a '0a'. The '\r' is (I think) a hex '0d' only. If you vi that file, it may show a '^m' on the end of each line. Also, 'file setup_perflab.sh' may tell you that it's format is other than "ASCII text".
(I've seen where ascii files from alien systems have left a ^m on the end of each line. 'bash' doesn't like when a line is terminated improperly -- it tags that character onto your command, whence the 'cd' failing, which makes the rest of the script fail...)
If this is the case, I'm not certain that 'dos2unix' will fix that file for you, but you can make a copy of the script and experiment on that copy. Otherwise you will have to edit the file to remove them, or use 'tr' to do the same.
Respond of this is the case or not. Thanks.
Brains, I agree with you. It's hard to remotely debug a problem when you are making assumptions regarding the distro, version, etc. But it is bash, and 3.2, so not too old. I'm hoping for bad termination characters.
Last edited by tommylovell; 07-25-2010 at 08:07 PM.
Reason: correct text
That one is tough. That file is being sourced. Sourced files often contain functions and often set environmental variables (I think it's safe to say that a file named "env" is going to set environmental variables).
I don't know much about Oracle. But since the Oracle systems I have access to have neither "setup_perflab.sh" nor a file named "env" (so these don't appear to be provided samples), my guess is that they were created locally. And given the name "setup_perflab.sh", it sounds local.
I think you need to find whoever created that shell script and ask them what "env" needs to contain. Certainly you need to set at least $PERFLAB_USER, but there may be more variables that are required by other scripts.
This command, when invoked from the command-line, executes a script. Within a script, a source file-name loads the file file-name. Sourcing a file (dot-command) imports code into the script, appending to the script (same effect as the #include directive in a C program). The net result is the same as if the "sourced" lines of code were physically present in the body of the script. This is useful in situations when multiple scripts use a common data file or function lib
It could have been ". $HOME/wkdir/env" for better readibility. It's a matter of preference.
You are correct.Script is showing the right way of executing . ./env. Now the script is working fine. I just used dos2unix command on env as well and it is executing without any errors.
Thank you so much for your help. Your expertise has made my first experience with this forum and linux a pleasant one.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.