LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 05-13-2011, 02:01 AM   #1
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Rep: Reputation: 12
problems with arguments when calling a script


Hi all

Suddenly, i have problems when i call a script when i use some arguments/variables
Here is my code
Code:
#!/bin/sh
PATH=""

find="/usr/bin/find"
xargs="/usr/bin/xargs"
tail="/usr/bin/tail"
awk="/usr/bin/awk"
cut="/usr/bin/cut"
wc="/usr/bin/wc"
grep="/bin/grep"
sqlplus="/usr/bin/sqlplus"

# Make sure the correct number of command line
# arguments have been supplied
if [ $# -lt 5 ]; then
    print_usage
    exit $STATE_UNKNOWN
fi

# Grab the command line arguments
exitstatus=$STATE_WARNING #default
while test -n "$1"; do
    case "$1" in
        --user)
            $user=$2
            shift
            ;;
	    -u)
            $user=$2
            shift
            ;;
	    --pass)
            $pass=$2
            shift
            ;;
	    -pa)
            $pass=$2
            shift
            ;;
	    --host)
            $host=$2
            shift
            ;;
	    -h)
            $host=$2
            shift
            ;;
	    --port)
            $port=$2
            shift
            ;;
	    -po)
            $port=$2
            shift
            ;;
	    --sid)
            $sid=$2
            shift
            ;;
	    -s)
            $sid=$2
            shift
            ;;
    esac
    shift
done

# DB Query:
queryresult=`$sqlplus $user/$pass@'(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=$host)(PORT=$port)))(CONNECT_DATA=(SID=$sid)))' << EOF
select *;
EOF`
This is my output:
Code:
# ./check_ORAdatabase_1.sh -u user -pa pass -h host -po port -s sid
./check_ORAdatabase_1.sh: line 73: =user: No such file or directory
./check_ORAdatabase_1.sh: line 81: =pa: No such file or directory
./check_ORAdatabase_1.sh: line 89: =host: No such file or directory
./check_ORAdatabase_1.sh: line 97: =port: No such file or directory
./check_ORAdatabase_1.sh: line 105: =sid: No such file or directory
OK - Nothing to report
why is this happening???

Thanks in advance
 
Old 05-13-2011, 02:08 AM   #2
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Original Poster
Rep: Reputation: 12
i've found the problem
when i search for my arguments or variables
i do
$user=$2

in stead of
user=$2

Code:
# Grab the command line arguments
exitstatus=$STATE_WARNING #default
while test -n "$1"; do
    case "$1" in
        --user)
            $user=$2
            shift
            ;;
	    -u)
            $user=$2
            shift
            ;;
	    --pass)
            $pass=$2
            shift
            ;;
	    -pa)
            $pass=$2
            shift
            ;;
	    --host)
            $host=$2
            shift
            ;;
	    -h)
            $host=$2
            shift
            ;;
	    --port)
            $port=$2
            shift
            ;;
	    -po)
            $port=$2
            shift
            ;;
	    --sid)
            $sid=$2
            shift
            ;;
	    -s)
            $sid=$2
            shift
            ;;
    esac
    shift
done
 
Old 05-13-2011, 02:20 AM   #3
prayag_pjs
Senior Member
 
Registered: Feb 2008
Location: Pune - India
Distribution: Fedora,RedHat,CentOS,Gentoo
Posts: 1,142
Blog Entries: 4

Rep: Reputation: 147Reputation: 147
Hi,

When you run this command as it is

Code:
# ./check_ORAdatabase_1.sh -u user -pa pass -h host -po port -s sid
you will get error as you need to replace user with some user on system and pass with actual password.
values in the argument are misssing.

are you running this script for the first time and also this script is written by you or you downloaded it?
 
Old 05-13-2011, 02:28 AM   #4
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Original Poster
Rep: Reputation: 12
euh... yeah i'm aware of that, but i don't say what user and pass i'm using
i don't use that command as i say it here
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing arguments to shell script like perl script get-opts somupl86 Linux - Newbie 2 12-02-2010 11:14 PM
how to pass a variable from a called script back to the calling script steven.c.banks Linux - General 2 05-05-2008 02:00 PM
Directory listing - Calling shell script from a CGI script seran Programming 6 08-11-2005 11:08 PM
calling another program alongwith arguments using execl not working sebythomas Programming 1 06-02-2005 12:37 PM
wine doesn't pass arguments correctly when calling programs jonchapman Linux - Software 0 10-08-2003 01:56 PM


All times are GMT -5. The time now is 03:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration