LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-29-2011, 04:36 PM   #1
sadosan83
LQ Newbie
 
Registered: Dec 2011
Posts: 4

Rep: Reputation: Disabled
bash script config file


hi all

config.sh :
------------
dhcp="0"
setip="1"
telnet="1"
ping="1"
.
.


main.sh
---------

function dhcp {

}

function setip {

}

function telnet {

}
.
.


I have a question, If the variable is 1 in the config file,how to call it function name, variable is not set or "0" not call function.

thanks all
 
Old 12-29-2011, 05:49 PM   #2
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
There are many ways to do it...
A bash way
Code:
(("$telnet")) && telnet
...

Last edited by Cedrik; 12-29-2011 at 05:51 PM.
 
Old 12-29-2011, 07:02 PM   #3
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Cedrik, that is the Bash way indeed. Incomprehensible for the unprepared user . I prefer verbatim tests:

Code:
if [ $telnet -eq 1]
do
    telnet
fi
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] changing a line in a config file while installing the program using bash script Joe_Louis Programming 11 07-23-2011 05:05 AM
Store user input in a config file GUI for a BASH script vaniaspeedy Linux - General 1 12-05-2010 12:08 AM
bash script: use the directory of the script file as variable? phling Linux - Newbie 12 01-16-2010 07:16 PM
[Req]: How to config WebSvr & DNS Svr from console by Bash shell script CiF Linux - Networking 2 03-22-2005 12:31 AM
bash scripting - how to make config file? Neorio Programming 3 10-22-2004 06:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:56 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
Open Source Consulting | Domain Registration