Sponsored Content
Top Forums UNIX for Dummies Questions & Answers if...elif...fi condition in Unix Post 27500 by abidmalik on Monday 2nd of September 2002 08:51:10 PM
Old 09-02-2002
if...elif...fi condition in Unix

Hey guyes!

i have a little problem in if condition, can anybody please solve my problem?

Here what i am doing.
Code:
if [ $int1 = $int2 ]
then
       echo "int1 is equal to int2"
elif [ $int1 > $int2 ]
then
       echo "int1 is greater than int2"
else
     echo "int1 is smaller than int2"
fi

No, matter int1 is smaller than int2 it says int1 is greater than int2, even thoug i put small value for int1.

it did not go to last "else" part (int1 is smaller than int2) why ?
am i doing something wrong ? please help me.

thanks
Abid Malik

added code tags for readability --oombera

Last edited by oombera; 02-19-2004 at 05:26 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If and Or Condition in Unix [ksh]

I have the code below. I want to said If TrackErrors > 0 or count == 0 then MailErrors else MailSuccess fi. if then MailErrors ${count} else MailSuccess ${count} fi Any helps greatly appreciated. (2 Replies)
Discussion started by: leemjesse
2 Replies

2. Shell Programming and Scripting

If..elif..else...fi

Hi all, I got some problems on executing the following scripts. Scripts: if ]; then echo "M${str}O 0 1" >> ${tempFile} elif ]; then echo "M${str}O 1 0" >> ${tempFile} else echo "M${str}O 0 0" >> ${tempFile} fi Error: "`;' is not expected." what's the problem? (2 Replies)
Discussion started by: Rock
2 Replies

3. Shell Programming and Scripting

Unix and db2 where condition issue(new line)

Hi I am extracting a column value(DESCRIPTION) from one table and passing it to another db2 statement in a shell code to fetch some value(ID) but the value when passed in where condition is taking as newline+value. Please find the out put when executed: + echo description is ::::... (1 Reply)
Discussion started by: msp2244
1 Replies

4. Shell Programming and Scripting

if condition to check the hostname (unix)

I want to know the if condition in checking the hostname in unix and then running a cron job (all in a single line) Thanks (2 Replies)
Discussion started by: prash358
2 Replies

5. Shell Programming and Scripting

how to use split command in unix shell with a condition

Hi all, I have a file which I want to split into several files based on a condition. This files has several records. I want one record per file. Each record ends with a //. So, I want to separate files based on this condition. I want split files to be named with the name across the field ID (for... (2 Replies)
Discussion started by: kaav06
2 Replies

6. Shell Programming and Scripting

Condition checking in UNIX

i have a script where i have to find the age of a file, if then echo "dnb file is present for the monthly load" >> $RUNLOG dnb="1" else echo "dnb file has not arrived yet" > $ERRLOG dnb="0" fi i know the file is available so... (3 Replies)
Discussion started by: lovelysethii
3 Replies

7. Shell Programming and Scripting

Checking for null condition in a UNIX variable

i have this code for i in `cat sql_output.txt` do -- some script commands done sql_output.txt has 1 column with employee_ids If the sql_output.txt is null then the do loop should not execute. How can i implement this. for i in `cat sql_output.txt` If i is null or empty then ... (5 Replies)
Discussion started by: rafa_fed2
5 Replies

8. Shell Programming and Scripting

If Condition Issue in UNIX

Hi I am trying to do a "IF" Condition in UNIX where we compare EACH file size in a directory with a SIZE (Parameter passed) If Each File size EXCEEDS parameter passed SIZE then we manipulate the file. Somehow the IF condition do not work ?? (is this Variable decalration issue ??) ... (9 Replies)
Discussion started by: Pete.kriya
9 Replies

9. UNIX for Advanced & Expert Users

How to create folder by using if and elif condition?

Hi All, I have already code to create folder for one country let say US , now we want to create folder/directory for JP country also using shell script , application server. $COUNTRY='US' if ] then if mkdir -m 777 -p /opt/TEST/$COUNTRY/$INVOICE >/dev/null 2>&1 | tee -a ... (5 Replies)
Discussion started by: Boost
5 Replies

10. Shell Programming and Scripting

Issue with condition "if then elif else fi"

Hi everybody, I must get trought a shell script 3 arguments. 1st argument = $1 (can take values REP1..4) 2nd argument = $2 (can take values A..Z) 3rd arguement = $3 (also can take values A...Z) I've written this code : #!/bin/bash if then liste=/data/folder1 echo... (6 Replies)
Discussion started by: shellX
6 Replies
GladeXML(3pm)						User Contributed Perl Documentation					     GladeXML(3pm)

NAME
Gtk2::GladeXML - Create user interfaces directly from Glade XML files. SYNOPSIS
# for a pure gtk+ glade project use Gtk2 -init; use Gtk2::GladeXML; $gladexml = Gtk2::GladeXML->new('example.glade'); $gladexml->signal_autoconnect_from_package('main'); $quitbtn = $gladexml->get_widget('Quit'); Gtk2->main; # for glade files using gnome widgets, you must initialize Gnome2 # before loading the glade file. use Gnome2; use Gtk2::GladeXML; # this call also initializes gtk+ for us Gnome2::Program->init ($appname, $version); $gladexml = Gtk2::GladeXML->new('gnomeapp.glade'); Gtk2->main; ABSTRACT
Gtk2::GladeXML allows Perl programmers to use libglade, a C library which generates graphical user interfaces directly from the XML output of the Glade user interface designer. DESCRIPTION
Glade is a free user interface builder for GTK+ and GNOME. After designing a user interface with glade-2 the layout and configuration are saved in an XML file. libglade is a library which knows how to build and hook up the user interface described in the Glade XML file at application run time. This extension module binds libglade to Perl so you can create and manipulate user interfaces in Perl code in conjunction with Gtk2 and even Gnome2. Better yet you can load a file's contents into a PERL scalar do a few magical regular expressions to customize things and the load up the app. It doesn't get any easier. FUNCTIONS
$gladexml = Gtk2::GladeXML->new(GLADE_FILE, [ROOT, DOMAIN]) Create a new GladeXML object by loading the data in GLADE_FILE. ROOT is an optional parameter that specifies a point (widget node) from which to start building. DOMAIN is an optional parameter that specifies the translation domain for the xml file. $gladexml = Gtk2::GladeXML->new_from_buffer(BUFFER, [ROOT, DOMAIN]) Create a new GladeXML object from the scalar string contained in BUFFER. ROOT is an optional parameter that specifies a point (widget node) from which to start building. DOMAIN is an optional parameter that specifies the translation domain for the xml file. $widget = $gladexml->get_widget(NAME) Return the widget created by the XML file with NAME or undef if no such name exists. $gladexml->signal_autoconnect($callback[, $userdata]) Iterates over all signals and calls the given callback: sub example_cb { my ($name, $widget, $signal, $signal_data, $connect, $after, $userdata) = @_; } The following two convenience methods use this to provide a more convenient interface. $gladexml->signal_autoconnect_from_package([PACKAGE or OBJECT]) Sets up the signal handling callbacks as specified in the glade XML data. The argument to this method can be a Perl package name or an object. If a package name is used, each handler named in the Glade XML data will be called as a subroutine in the named package. If an object is supplied each handler will be called as a method of the object. If no argument is supplied, the name of the calling package will be used. A user data argument cannot be supplied however this is seldom necessary when an object is used. The names of the subroutines or methods must exactly match the handler name in the XML data. It is worth noting that callbacks you get for free in c such as gtk_main_quit will not exist in perl and must always be defined, for example: sub gtk_main_quit { Gtk2->main_quit; } Otherwise behavior should be exactly as expected with the use of libglade from a C application. $gladexml->signal_autoconnect_all (name => handler, ...) Iterates over all named signals and tries to connect them to the handlers specified as arguments (handlers not given as argument are being ignored). This is very handy when implementing your own widgets, where you can't use global callbacks. $widget = Gtk2::Glade->set_custom_handler ($callback[, $userdata]) This method tells Gtk2::GladeXML how to create handlers for custom widgets. You can specify a "custom" widget in a glade file, which allows you to include in your interface widgets that Glade itself doesn't know how to create. To tell libglade how to instantiate such widgets, you specify a "custom widget handler", a function which returns a Gtk2:Widget object for that custom widget. This handler needs to be installed sometime before the instantiation of your Gtk2::GladeXML object, by calling "set_custom_handler". my $widget = Gtk2::Glade->set_custom_handler( &my_handler ); my $gladexml = Gtk2::GladeXML->new( 'MyApp.glade' ); The prototype for the custom handler is: sub my_handler { my ($xml, # The Gtk2::GladeXML object # the remaining arguments are as specified in the glade file: $func_name, # The function name $name, # the name of the widget to be created $str1, # the string1 property $str2, # the string2 property $int1, # the int1 property $int2, # the int2 property $userdata # the data passed to set_custom_handler ) = @_; ... return $widget; # a new Gtk2::Widget; you must call ->show on it. } FAQ
Where is the option to generate Perl source in Glade? Glade itself only creates the XML description, and relies on extra converter programs to write source code; only a few converters are widely popular. In general, however, you don't want to generate source code for a variety of reasons, mostly to do with maintainability. This message on the glade-devel list explains it best: http://lists.ximian.com/archives/public/glade-devel/2003-February/000015.html Why does my program crash on startup? Does your glade file use Gnome widgets? If so, you must initialize Gnome manually; libglade can knows how to create gnome widgets, but can't know how you want to initialize the app. This is usually sufficient: use Gnome2; Gnome2::Program->init ($app_name, $version_string); Libglade's API reference mentions this: http://developer.gnome.org/doc/API/2.0/libglade/libglade-modules.html SEE ALSO
perl(1), Glib(3pm), Gtk2(3pm) The Libglade Reference Manual at <http://developer.gnome.org/doc/API/2.0/libglade/> An introductory article that originally appeared in The Perl Review: http://live.gnome.org/GTK2-Perl/GladeXML/Tutorial <http://live.gnome.org/GTK2-Perl/GladeXML/Tutorial> AUTHOR
Ross McFarland <rwmcfa1 at neces dot com>, Marc Lehmann <pcg@goof.com>, muppet <scott at asofyet dot org>. Bruce Alderson provided several examples. Grant McClean <grant at mclean dot net dot nz> and Marco Antonio Manzo <amnesiac at perl dot org dot mx> contributed documentation. COPYRIGHT AND LICENSE
Copyright 2003-2006 by the gtk2-perl team. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA. perl v5.14.2 2008-09-07 GladeXML(3pm)
All times are GMT -4. The time now is 04:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy