[Solved] Get username, etc. from config file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [Solved] Get username, etc. from config file
# 1  
Old 01-01-2012
[Solved] Get username, etc. from config file

how can i get the database name from a config file

its like this:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'userabc_wrdp1');

(there might be spaces in the front of "define")

i want to store the database name to a variable
$dbname=

thanks!

---------- Post updated at 04:33 AM ---------- Previous update was at 04:06 AM ----------

i tried this but it doesnt work Smilie
Code:
dbname=`grep '^define.*DB_NAME' $theconfigfile | cut -d "'" -f4`

its giving output like
Code:
grep: That's: No such file or directory
grep: all,: No such file or directory
grep: stop: No such file or directory
grep: editing!: No such file or directory
grep: Happy: No such file or directory
grep: blogging.: No such file or directory
: No such file or directory
: No such file or directory
grep: WordPress: No such file or directory
grep: absolute: No such file or directory
grep: path: No such file or directory

---------- Post updated at 04:46 AM ---------- Previous update was at 04:33 AM ----------

i tried:


grep "^ *define.*DB_NAME" grep "^ *define.*DB_NAME" $FILE | cut -d "'" -f4


it works on the command line but not in the shell script
im not sure the syntax

---------- Post updated at 04:54 AM ---------- Previous update was at 04:46 AM ----------

i was using the wrong config file

i got it to work
like

Code:
dbname=`grep "^ *define.*DB_NAME" $configfile | cut -d "'" -f4`


Last edited by vbe; 01-01-2012 at 07:19 AM.. Reason: thanks for the information... but use code tags next time
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

[solved]Config/enable_mapping missing, how to add?

Issue resolved by upgrading from solaris 11 to solaris 11.1 I would like to enable network mapping. While using instructions from: https://blogs.oracle.com/VDIpier/entry/solaris_11_changing_the_hostname To change my hostname I noticed I am missing the enable mapping bool. What it should... (0 Replies)
Discussion started by: taltamir
0 Replies

2. Shell Programming and Scripting

[Solved] I need to parse an username in parameters

Hi! Thank you ina advance for your Help. Sorry my english, Im from Argentina! Great Place!!! So, here si my problem I have a variable, lets say PARAMETERS that could be set like this: PARAMETROS="-Usistemas string1 -Astring2 -G -Y -Kcoco -Y string4 -Z" or PARAMETROS="string1... (1 Reply)
Discussion started by: Hercraft
1 Replies

3. Shell Programming and Scripting

help, extract username from file

there is a text file like this text here text here text here text here USER=someusername here text here text here text here how can i extract the someusername from this file which has a path like /home/myfile.txt? i want to store it in a variable $u (3 Replies)
Discussion started by: vanessafan99
3 Replies

4. Shell Programming and Scripting

Get username of last user to modify a file

Possible to get this? Thanks (2 Replies)
Discussion started by: stevensw
2 Replies

5. Shell Programming and Scripting

Shell script that will compare two config files and produce 2 outputs 1)actual config file 2)report

Hi I am new to shell scripting. There is a requirement to write a shell script to meet follwing needs.Prompt reply shall be highly appreciated. script that will compare two config files and produce 2 outputs - actual config file and a report indicating changes made. OS :Susi linux ver 10.3. ... (4 Replies)
Discussion started by: muraliinfy04
4 Replies

6. Shell Programming and Scripting

[solved] merging two files and writing to another file- solved

i have two files as file1: 1 2 3 file2: a b c and the output should be: file3: 1~a 2~b 3~c (1 Reply)
Discussion started by: mlpathir
1 Replies

7. Shell Programming and Scripting

SOLVED: reading config file in a perl script

Hi! I have a need to do this in Perl. script.pl -config file The script would be doing a wget/LWP on a URL which is defined in the config file. So when I run the script it should return either one of these conditions - 1) OK with exit status 0. Should also print "wget URL" 2)... (6 Replies)
Discussion started by: jacki
6 Replies

8. Shell Programming and Scripting

parsing config file to create new config files

Hi, I want to use a config file as the base file and parse over the values of country and city parameters in the config file and generate separate config files as explained below. I will be using the config file as mentioned below: (config.txt) country:a,b city:1,2 type:b1... (1 Reply)
Discussion started by: clazzic
1 Replies

9. Shell Programming and Scripting

Need to modify a file of different username through script.

Hi ! All I want to write a script where, it will open a new shell with a username / pwd and modify a file of same username and exit. example: 1. UserA 2. UserB- FileB ScriptA -> su UserB -> Modify FileB -> Exit ScriptA Can somebody give me a direction , on how to... (2 Replies)
Discussion started by: dashok.83
2 Replies

10. UNIX for Dummies Questions & Answers

How to get the Username stored in another file

Hello, I have a file FSGReport.info which reads as export username=abc export password= 1333 Now I have another FTP script file FTP.sh in which I need to access the username and password stored in the file FSGReport.info . How can I access this file and get the username and password. Please... (1 Reply)
Discussion started by: vnatarajan
1 Replies
Login or Register to Ask a Question