- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: if statement in the scripting
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
Discussions
Discussions
Forums
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
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
тАО10-27-2008 12:59 AM
тАО10-27-2008 12:59 AM
if statement in the scripting
I am executing one program . But that is showing errors. Please is help me.
My program is:
echo $int1
echo $int2
if [ "$int1" -eq "$int2" ]
then
echo "command was successful"
elif
echo "command was unsuccessfull"
fi
I want in the execution time i want to assign the numbers for int1 and int2. Please tell me how to assign the numbers in execution time.
thanx & Regards,
Anji.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2008 01:13 AM
тАО10-27-2008 01:13 AM
Re: if statement in the scripting
Use
read int1 and read int2 at the begining.
Aneesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2008 01:16 AM
тАО10-27-2008 01:16 AM
Re: if statement in the scripting
to assign a value to a variable:
varname=varvalue
echo $varname
to debug your script you can set "set -x" after "#!/usr/bin/ksh"
#!/usr/bin/ksh
set -x
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2008 01:29 AM
тАО10-27-2008 01:29 AM
Re: if statement in the scripting
If you want the script to prompt you for the variable at the time of execution then you may need to do
echo "Reading the value of int1 :\c"
read int1
echo "Reading the value of int2 :\c"
read int2
if [ "$int1" = "$int2" ]
then
echo "command was successful"
else
echo "command was unsuccessfull"
fi
If you want assign a value in the script with out prompting then
int1=xyz
int2=xyz
Aneesh
Aneesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2008 01:49 AM
тАО10-27-2008 01:49 AM
Re: if statement in the scripting
I can see you were not assigned points for previous thread,please assign point if our replies helped.
Aneesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2008 02:05 AM
тАО10-27-2008 02:05 AM
Re: if statement in the scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2008 02:37 AM
тАО10-27-2008 02:37 AM
Re: if statement in the scripting
read int1
read int2
if [ "$int1" -eq "$int2" ]
then
echo "command was successful"
elif
then
echo "command was unsuccessfull"
fi
I tried like above . But Iam getting errors. please give me the instructions.
Regards,
Anji.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2008 03:00 AM
тАО10-27-2008 03:00 AM
Re: if statement in the scripting
Please help me. iam two errors.
fi unexpected
then unexpected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2008 03:02 AM
тАО10-27-2008 03:02 AM
Re: if statement in the scripting
elif
use else:
#!/usr/bin/ksh
read int1
read int2
if [[ "$int1" -eq "$int2" ]]
then
echo "command was successful"
else
echo "command was unsuccessfull"
fi
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2008 03:14 AM
тАО10-27-2008 03:14 AM
Re: if statement in the scripting
I tried Iam getting wrong output:
#!/usr/bin/ksh
read int1
read int2
if [["$int1" -eq "$int2"]]
then
echo "command was successful"
else
echo "command was unsuccessfull"
fi
OUTPUT:-
$ sh test1
3
3
test1: [[3: not found
command was unsuccessfull