Linux - Newbie This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
|
07-25-2010, 01:47 PM
|
#1
|
|
LQ Newbie
Registered: Jul 2010
Location: NJ
Distribution: i686-redhat linux gnu 3.2.25
Posts: 10
Rep:
|
command not found error while executing a shell script
Hello,
I am a newbie to linux.I am attaching the code which gives me following errors..
error list:
1. no such file or directory enviornemnt
2. command not found
3. ambiguous redirectline
Script
cd $HOME/wkdir
#
#
#
rm /tmp/*.log
#
# source environment
#
. ./env
#
# 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(
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
dbms_application_info.set_module('DEMO', name);
WHILE (nexec_it < nexec)
LOOP
curs := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(curs, stmt, DBMS_SQL.NATIVE);
rc := DBMS_SQL.EXECUTE(curs);
nrows_it := 0;
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;
nrows_it := nrows_it + 1;
END LOOP;
DBMS_SQL.CLOSE_CURSOR(curs);
nexec_it := nexec_it + 1;
END LOOP;
dbms_application_info.set_module(null, null);
END fetch_n_rows;
/
show errors
!
#
# Start the workload
#
. ./start_workload.sh > /tmp/setup_perflab.log 2>&1
#
# Wait two minutes for workload to get going
#
sleep 120
#
# 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);
EOF
Note : start_workload.sh is also in the same directory..
Any help would be greatly appreciated.
|
|
|
|
07-25-2010, 03:04 PM
|
#2
|
|
Member
Registered: Apr 2009
Distribution: Debian testing
Posts: 254
Rep:
|
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:
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.
|
|
|
|
07-25-2010, 03:43 PM
|
#3
|
|
LQ Newbie
Registered: Jul 2010
Location: NJ
Distribution: i686-redhat linux gnu 3.2.25
Posts: 10
Original Poster
Rep:
|
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.
|
|
|
|
07-25-2010, 03:57 PM
|
#4
|
|
Member
Registered: Apr 2009
Distribution: Debian testing
Posts: 254
Rep:
|
Quote:
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.
Last edited by Brains; 07-25-2010 at 04:00 PM.
|
|
|
|
07-25-2010, 04:32 PM
|
#5
|
|
LQ Newbie
Registered: Jul 2010
Location: NJ
Distribution: i686-redhat linux gnu 3.2.25
Posts: 10
Original Poster
Rep:
|
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.
|
|
|
|
07-25-2010, 06:09 PM
|
#6
|
|
Member
Registered: Nov 2005
Distribution: Fedora, Redhat
Posts: 372
Rep: 
|
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 ~]#
SurbhiJain, see the 3.6.6 section of http://www.gnu.org/software/bash/manual/bashref.html for an explanation of what the "<<!" does.
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.
|
|
|
|
07-25-2010, 06:25 PM
|
#7
|
|
LQ Newbie
Registered: Jul 2010
Location: NJ
Distribution: i686-redhat linux gnu 3.2.25
Posts: 10
Original Poster
Rep:
|
hi tommylovell,
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 .
thanks
|
|
|
|
07-25-2010, 07:34 PM
|
#8
|
|
Member
Registered: Apr 2009
Distribution: Debian testing
Posts: 254
Rep:
|
Quote:
|
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.
|
|
|
|
07-25-2010, 07:51 PM
|
#9
|
|
LQ Newbie
Registered: Jul 2010
Location: NJ
Distribution: i686-redhat linux gnu 3.2.25
Posts: 10
Original Poster
Rep:
|
hmmm. will do...but cud u pls tell me why are those errors coming?
|
|
|
|
07-25-2010, 07:57 PM
|
#10
|
|
Member
Registered: Nov 2005
Distribution: Fedora, Redhat
Posts: 372
Rep: 
|
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
|
|
|
|
07-25-2010, 09:06 PM
|
#11
|
|
LQ Newbie
Registered: Jul 2010
Location: NJ
Distribution: i686-redhat linux gnu 3.2.25
Posts: 10
Original Poster
Rep:
|
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?
|
|
|
|
07-25-2010, 10:17 PM
|
#12
|
|
Member
Registered: Nov 2005
Distribution: Fedora, Redhat
Posts: 372
Rep: 
|
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.
|
|
|
|
07-25-2010, 11:35 PM
|
#13
|
|
Member
Registered: Apr 2009
Distribution: Debian testing
Posts: 254
Rep:
|
I know nothing about Oracle. But at line 13 of the script, something looks funny to me and I highlight it in red below:
Code:
#
# source environment
#
. ./env
#
# Run the install script to setup the database
Should it not be as in the example below?
Code:
#
# source environment
#
./env
#
# Run the install script to setup the database
|
|
|
|
07-26-2010, 09:07 AM
|
#14
|
|
Member
Registered: Nov 2005
Distribution: Fedora, Redhat
Posts: 372
Rep: 
|
No, I don't think so. I beleive ". ./env" is correct. It just looks peculiar.
The first '.' is to "source the ./env file".
See http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x237.html
Or better yet, http://tldp.org/LDP/abs/html/internal.html
Quote:
source, . (dot command)
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.
|
|
|
|
07-26-2010, 09:16 AM
|
#15
|
|
LQ Newbie
Registered: Jul 2010
Location: NJ
Distribution: i686-redhat linux gnu 3.2.25
Posts: 10
Original Poster
Rep:
|
hi tommylevell,
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.
Surbhi
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 07:10 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|