- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: shell script error
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2008 09:42 PM
03-10-2008 09:42 PM
eg:12 and 13 it showing mathcing
12 and 12 also showing matching.
#!/usr/bin/sh
echo "enter the number"
read number1
echo "enter the number"
read number2
if number1=number2
then
echo "matching"
exit
else number1!=number2
echo "Not matching"
fi
exit
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2008 09:51 PM
03-10-2008 09:51 PM
Re: shell script error
when working with the variables you should use the $ sign.
e.g.
if $number1 = $number2
then
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2008 09:52 PM
03-10-2008 09:52 PM
Re: shell script error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2008 09:55 PM
03-10-2008 09:55 PM
Re: shell script error
below the modified script:
$ vi script1.sh
#!/usr/bin/sh
echo "enter the number"
read number1
echo "enter the number"
read number2
if [ $number1 = $number2 ]
then
echo "matching"
exit
else [ $number1 != $number2 ]
echo "Not matching"
fi
exit
~
~
~
~
~
~
~
~
~
"script1.sh" 14 lines, 200 characters
$ ./script1.sh
enter the number
12
enter the number
13
Not matching
$
hope this helps!
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2008 09:58 PM
03-10-2008 09:58 PM
Solutionbelow a more readable output:
$ vi script1.sh
#!/usr/bin/sh
echo "enter the number"
read NUMBER1
echo "enter the number"
read NUMBER2
if [ $NUMBER1 = $NUMBER2 ]
then
echo "matching"
exit
else [ $NUMBER1 != $NUMBER2 ]
echo "Not matching"
fi
exit
~
~
~
~
~
~
~
~
~
"script1.sh" 14 lines, 200 characters
$ ./script1.sh
enter the number
12
enter the number
12
matching
$ r
./script1.sh
enter the number
12
enter the number
13
Not matching
$
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2008 10:25 PM
03-10-2008 10:25 PM
Re: shell script error
echo "enter the number"
read NUMBER1
echo "enter the number"
read NUMBER2
if $NUMBER1=$NUMBER2
($NUMBER1 = $NUMBER2 I TESTED THIS ONE ALSO)
then
echo "matching"
else
echo "Not matching"
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2008 11:09 PM
03-10-2008 11:09 PM
Re: shell script error
still it showing error
i don't why i am still confusing
#!/usr/bin/sh
echo "enter the Number"
read NUMBER1
echo "enter the Number"
read NUMBER2
if [$NUMBER1= $NUMBER2]
then
echo "matching"
exit
else [$NUMBER1 != $NUMBER2]
echo "Not matching"
fi
exit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2008 11:30 PM
03-10-2008 11:30 PM
Re: shell script error
I wrote in the same way but i am not getting
any parmeter missing or somethign like that
or file permission some thing like that
#!/usr/bin/sh
echo "enter the Number"
read NUMBER1
echo "enter the Number"
read NUMBER2
if [ $NUMBER1= $NUMBER2 ]
then
echo "matching"
exit
else [ $NUMBER1 != $NUMBER2 ]
echo "Not matching"
fi
exit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2008 12:19 AM
03-11-2008 12:19 AM
Re: shell script error
I can execute the following script without any error.
#!/usr/bin/sh
echo "enter the Number"
read NUMBER1
echo "enter the Number"
read NUMBER2
if [ $NUMBER1 -eq $NUMBER2 ]
then
echo "matching"
exit
else [ $NUMBER1 != $NUMBER2 ]
echo "Not matching"
fi
exit
For setting the execution permission, use the command:
#chmod u+x filename.
If you want a trial run of the script without setting the execution permition use:
# sh filename
Regards,
Davis Paul.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2008 12:22 AM
03-11-2008 12:22 AM
Re: shell script error
i gave already that permission
also
./
sh etc...
any how others can excute this one without
erro
but i am getting error
i don't why?
it is amazing me
sajjad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2008 01:00 AM
03-11-2008 01:00 AM
Re: shell script error
it could be a problem with spaces in the script...
am attaching the code in a text file.
Please download and run it.
$ chmod +x script1.sh
$ ./script1.sh
revert
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2008 02:19 AM
03-11-2008 02:19 AM
Re: shell script error
Please post the error messages which you are getting now.
Regards,
Davis Paul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2008 02:20 AM
03-11-2008 02:20 AM
Re: shell script error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2008 08:00 AM
03-11-2008 08:00 AM
Re: shell script error
You haven't closed the thread.
Also, if any answers here are useful, you need to assign points before you close it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2008 11:53 AM
03-11-2008 11:53 AM
Re: shell script error
also, the original poster needs to be aware that the tests indicated are for matching strings , so "1" and "01", while numerically equal fail as the strings differ
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2008 04:48 PM
03-11-2008 04:48 PM
Re: shell script error
-eq -ne -gt -ge -lt -le
Note that the strings 1 9 22 777 will compare (sort) in this order:
1
22
777
9
but as numbers, they will sort this way:
1
9
22
777
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2008 09:27 PM
03-11-2008 09:27 PM
Re: shell script error
here is the correct information of the script:
#!/usr/bin/sh
echo "enter the number"
read number1
echo "enter the number"
read number2
if [ $number1 = $number2 ]
then
echo "matching"
exit
else
echo "Not matching"
fi
Thanks & Regards
Aashique
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2008 02:00 AM
03-13-2008 02:00 AM
Re: shell script error
I thank you for making these clarifications. I was not really aware of these *Intricacies* in shell scripting... :(
it seems that the last poster did not read your post properly, so i will post the new script with corrections made as per your recommendations:
#!/usr/bin/sh
echo "enter the number"
read number1
echo "enter the number"
read number2
if [ $number1 -eq $number2 ]
then
echo "matching"
exit
else [ $number1 -ne $number2 ]
echo "Not matching"
fi
Sorry for inconvenices!
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2008 11:11 PM
03-14-2008 11:11 PM