LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 01-20-2004, 04:35 PM   #1
kalleanka
Member
 
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 547

Rep: Reputation: 38
Unhappy Bash script problem


hi,

If I call my bash script (openfirebird) from commandline it works fine but if I run it my program (kdevelop) it does not work as expected. The if statment is always false and
$FBDIR/MozillaFirebird -remote "xfeDoCommand(openBrowser)" & is called. This givs a error: No running window found.

If i got an instance of the browser it works fine.

Any idees!


The script is simple:

#!/bin/bash

#script by Kent Le (double_deuce@hotmail.com)
#written in October, 2003

FBNUM=`ps -A | grep -c MozillaFirebird`
#really freaking ugly hack: counts number of already running instances of firebird
FBDIR=/usr/lib/MozillaFirebird/
#directory of Firebird directory; modify to your own

if [[ FBNUM -lt 1 ]]
#if no running instances -eq equal -lt less than
then
$FBDIR/MozillaFirebird &
else
#otherwise, there is at least one instance of firebird running
$FBDIR/MozillaFirebird -remote "xfeDoCommand(openBrowser)" &
#open a new browser instance
fi


and in the program :
system("/usr/lib/MozillaFirebird/openfirebird");
Where the script is openfirebird.


Thanks!
 
Old 01-20-2004, 04:56 PM   #2
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
Re: Bash script problem

Quote:
Originally posted by kalleanka
if [[ FBNUM -lt 1 ]]
$FBNUM?
 
Old 01-30-2004, 12:59 PM   #3
kalleanka
Member
 
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 547

Original Poster
Rep: Reputation: 38
Wink

Ok i rewrote the if-statement and now it works fine.

Here is a nice site all hackers should read or should have read. http://www.possibility.com/Cpp/CppCodingStandard.html



The Bull of Boolean Types

Any project using source code from many sources knows the pain of multiple conflicting boolean types. The new C++ standard defines a native boolean type. Until all compilers support bool, and existing code is changed to use it, we must still deal with the cruel world.

The form of boolean most accurately matching the new standard is:

typedef int bool;
#define TRUE 1
#define FALSE 0

or

const int TRUE = 1;
const int FALSE = 0;

Note, the standard defines the names true and false not TRUE and FALSE. The all caps versions are used to not clash if the standard versions are available.

Even with these declarations, do not check a boolean value for equality with 1 (TRUE, YES, etc.); instead test for inequality with 0 (FALSE, NO, etc.). Most functions are guaranteed to return 0 if false, but only non-zero if true. Thus,

if (TRUE == func()) { ...

must be written
if (FALSE != func()) { ...
 
  


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
Problem with bash script. cheater1034 Programming 9 11-21-2005 11:29 PM
bash script problem fatbastard spice Linux - General 2 08-24-2005 03:15 AM
bash script problem GATTACA Programming 3 06-13-2005 10:59 AM
bash script problem sorry99 Programming 2 09-20-2004 10:02 AM
Problem with bash script cowardnewbie Programming 1 10-01-2001 07:53 AM


All times are GMT -5. The time now is 05:13 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration