Results 1 to 6 of 6

Thread: Bash script to import variable configuration

  1. #1
    Join Date
    Aug 2010
    Posts
    40

    Bash script to import variable configuration

    Hello,
    Here is the script I am working on
    Code:
    # / Bin / bash if [-e / opt / topnet / mnt / mysql.pipe] then while [-e / opt / topnet / mnt / mysql.pipe] do mysql-u syslog - password = syslog-D syslog </ opt / topnet / mnt / done else mkfifo mysql.pipe / opt / topnet / mnt / mysql.pipe fi
    the variable
    Code:
    $ User 
    $ Password 
    $ Base
    A configuration file is available and I did a test on it but the problem is that it is not working.

  2. #2
    Join Date
    Aug 2008
    Posts
    721

    Re: Bash script to import variable configuration

    Even I did had same problem and I created a file config
    Code:
    / Etc / config.cfg 
    VAR1 = v 
    VAR2 = w
    At the beginning of the script. I also added
    Code:
    source / etc / config.cfg

  3. #3
    Join Date
    Sep 2005
    Posts
    1,370

    Re: Bash script to import variable configuration

    Can you try to change you code to this and check whether it is working or not.
    Code:
    # / Bin / bash
    . . / Etc / mapping.cfg
    if [-e / opt / topnet / mnt / mysql.pipe] then while [-e / opt / topnet / mnt / mysql.pipe] do mysql-u $ database - password = syslog D-syslog </ opt / topnet / mnt / done else mkfifo mysql.pipe / opt / topnet / mnt / mysql.pipe fi
    The following should be replaced
    Code:
    mapping.cfg contains 
    base = db_name
    Finally change the mode
    Code:
    chmod + x / etc / mapping.cfg

  4. #4
    Join Date
    Apr 2008
    Posts
    3,339

    Re: Bash script to import variable configuration

    By cons, the syntax seems to me wrong in the second part of the script, when you want to declare varable SD:
    Code:
    SD = cat 'config'
    It seems to me that it would rather:
    Code:
    SD = $ (cat 'config')
    So that the "car" is executed because according to your syntax, your variable will be equal to SD Cat 'config "without the" cat "is executed.

  5. #5
    Join Date
    Aug 2008
    Posts
    721

    Re: Bash script to import variable configuration

    My problem is how to create a maintenance rpm that by installing
    Code:
    config / etc / mapping.cfg
    file / user / bin / mapping that contains the script
    Code:
    init file / etc / init.d /
    Mapping that allows the control rcmapping start / stop and status. By this you can take the complete control of the program.

  6. #6
    Join Date
    Aug 2010
    Posts
    37

    Re: Bash script to import variable configuration

    I have a question , if I do
    Code:
    SD = $ (cat 'config')
    then how I can access variable contained in the config file are of this type
    Code:
    user = bh
    password = t
    base = ata
    pipe = ex.pipe
    So that my script is
    Code:
    mysql-u $ user - password = $ password-D $ database </ opt / topnet / mnt / $ pipe
    Please help me with this. Thank you.

Similar Threads

  1. How to create CGI script in bash?
    By Mulan in forum Software Development
    Replies: 5
    Last Post: 01-09-2010, 08:19 PM
  2. Create bash script for ftp
    By teenQ in forum Operating Systems
    Replies: 4
    Last Post: 04-03-2010, 07:37 PM
  3. Bash script if then else help
    By Unix'EM in forum Software Development
    Replies: 3
    Last Post: 18-08-2009, 06:34 PM
  4. Create a bash script for sftp
    By Xubuntu_user in forum Operating Systems
    Replies: 3
    Last Post: 06-08-2009, 09:30 PM
  5. Exporting environment variable from a bash script
    By Unix'EM in forum Software Development
    Replies: 3
    Last Post: 06-08-2009, 05:52 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,268,244.01530 seconds with 17 queries