command not found error while executing a shell script
I am a newbie to linux.I am attaching the code which gives me following errors..
1. no such file or directory enviornemnt
2. command not found
3. ambiguous redirectline
# source environment
# Run the install script to setup the database
# Configure SH account
sqlplus "/ as sysdba" <<! > /tmp/perflab_install.log 2>&1
grant connect, resource, dba to SH;
alter user sh account unlock;
# create the fetch_n_rows procedure
sqlplus "$PERFLAB_USER" <<! >> /tmp/perflab_install.log 2>&1
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(
nexec NUMBER := 1,
nrows NUMBER := 0,
debug BOOLEAN := FALSE)
-- Local variables
curs INTEGER := null;
nexec_it INTEGER := 0;
WHILE (nexec_it < nexec)
curs := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(curs, stmt, DBMS_SQL.NATIVE);
rc := DBMS_SQL.EXECUTE(curs);
nrows_it := 0;
IF (dbms_sql.fetch_rows(curs) <= 0 OR (nrows <> 0 AND nrows_it = nrows
ELSE IF (debug = TRUE)
nrows_it := nrows_it + 1;
nexec_it := nexec_it + 1;
# Start the workload
. ./start_workload.sh > /tmp/setup_perflab.log 2>&1
# Wait two minutes for workload to get going
# Modify snapshot interval
sqlplus -s /NOLOG <<EOF >> /tmp/setup_perflab.log 2>&1
connect / as sysdba
set head on
set feedback on;
set pagesize 40
rem -- event to allow setting very short Flushing interval
alter session set events '13508 trace name context forever, level 1';
rem -- change INTERVAL setting to 2 minutes
rem -- change RETENTION setting to 6 hours (total of 180 snapshots)
execute dbms_workload_repository.modify_snapshot_settings(interval => 2,-
retention => 360);
Note : start_workload.sh is also in the same directory..
Any help would be greatly appreciated.
A few things you can/should do:
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:
Thanks for answering. I didnt understand how to edit and change the profile. If you can give the pointers.
I have given the permission by chmod 777
I think the script is executing but spitting out errors. Feel like the environment variables havent been set correctly. Listing the errors which i see
setup_perlab.sh line 12: grant: command not found
setup_perlab.sh line 13 : alter: command not found
Any help is greatly appreciated.
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.
Those are the sql commands which are trying to configure oracle user 'SH'.
ls -l start_workload.sh command shows :
-rwxrwxrwx 1 oracle oinstall 1075 jul 24 14:00 start_workload.s
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.
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.
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 .
hmmm. will do...but cud u pls tell me why are those errors coming?
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.
dos2unix command has surely helped me...Now it has come down to only one error that is :
'./setup_perflab.sh':line 13 :./env : No Such file or directory.
i think, it executes the script after showing the above error message but not sure will error message affect anyway?
Any pointers for solving the above error?
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.
Sorry I can't help with that.
I know nothing about Oracle. But at line 13 of the script, something looks funny to me and I highlight it in red below:
No, I don't think so. I beleive ". ./env" is correct. It just looks peculiar.
The first '.' is to "source the ./env file".
Or better yet, http://tldp.org/LDP/abs/html/internal.html
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.
|All times are GMT -5. The time now is 07:30 PM.|