source ... how to initiate once in linux or php


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting source ... how to initiate once in linux or php
# 1  
Old 01-16-2012
source ... how to initiate once in linux or php

Hi

I'm using this script for PHP purpose:

script.sh
-------------------------
Code:
#!/bin/bash
source app_path/config_file'
app_name $* script_name

the thing that bothers me is that every time I call app_app_name $* script_name I have to run source, which of course is required in this situation, but HOW TO MAKE IT RUN ONLY ONCE SOMEWHERE IN THE SYSTEM?

For instance if I put it in .bashrc it works fine when I open my linux console then I don't have to source again it reads .bashrc file, but PHP doesn't see this file so every time I call my application I need to source first as it is above in my script.

Moderator's Comments:
Mod Comment Please use next time code tags for your code and data

Last edited by vbe; 01-16-2012 at 12:35 PM..
# 2  
Old 01-16-2012
That's just how environment variables work. You can't change everyone's variables, only your own, and children get independent copies of every environment variable their parents have.

If you want something persistent and dynamic, i.e. make a change and everything sees it, then a database would be more appropriate, like mysql(which is very popular for use with php, and php supports almost everywhere). Or perhaps variables stored in sessions(which php again, supports almost everywhere).
# 3  
Old 01-16-2012
Just for the sake of illuminating me (since i know nothing about php), can't he use something like putenv and define his enviroment in php code both local and global ?
# 4  
Old 01-17-2012
thank you for reply. Sessions would be better then every time the same user as he clicks the link with the shell command is initiating the app enviroment, but how to do this? (or I should look for php forum).

putenv - I know nothing about this function only have read about it, but if it's possible and how...
# 5  
Old 01-17-2012
I actually told you about this last time you asked...

session_start

At the beginning of your PHP script (it's vital that it happens before anything is printed, even spaces).

Then you can use the special $_SESSION variable to hold things in, and ought to have them carried between script instances.
# 6  
Old 01-18-2012
Quote:
Originally Posted by Corona688
I actually told you about this last time you asked...
No, you just mentioned about session_start and I've read more in manual the same thing what you have written below. I asked for technical help, because I don't have this knowledge how to use sessions in my case.



Quote:
Originally Posted by Corona688
session_start

At the beginning of your PHP script (it's vital that it happens before anything is printed, even spaces).

Then you can use the special $_SESSION variable to hold things in, and ought to have them carried between script instances.
# 7  
Old 01-18-2012
I'm not sure what to tell you that the examples don't. Ask more specific questions and I'll give more specific answers.
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

UNIX/Linux inventory - Open Source

Hello guys, I need an open source tool that can list all the softwares installed in my unix/linux servers, the tool should list all the softwares installed and the current version, grouped by the hostname, anybody know any solution for this specific problem? Thanks guys, have a good day! (7 Replies)
Discussion started by: denisloide
7 Replies

2. Linux

Linux open source for admin

Hi, I have created my VM lab on redhat linux, but giving me error after updating new yum repository, its asking me for subscription. I want want switch my redhat linux lab from VM, which linux open source will be best to perform admin commands and tasks?? If possible , please provide iso file... (2 Replies)
Discussion started by: Nats
2 Replies

3. Shell Programming and Scripting

How to execute functions or initiate functions as command line parameters for below requirement?

I have 7 functions those need to be executed as command line inputs, I tried with below code it’s not executing function. If I run the ./script 2 then fun2 should execute , how to initiate that function I tried case and if else also, how to initiate function from command line if then... (8 Replies)
Discussion started by: saku
8 Replies

4. Programming

How to modify all Makefiles in a source tree into linux environment

Hi Frndz, I am new to the makefile generation. I have a source code which contains makefiles in each sub-directories. Previously we have used the entire source code in Dtbuild environment to get the executables. Now have to change the current Dtbuild environment to Linux build... (1 Reply)
Discussion started by: korraag
1 Replies

5. Shell Programming and Scripting

Linux source code

Unix is written in C. From where u can see the source code of unix or linux (1 Reply)
Discussion started by: pritish.sas
1 Replies

6. SuSE

How do I compile source undfer Suse Linux?

I've been usuing Suse 9.1 & 10 on 2 different machines for a while and have so far relied on ready compiled versions of programs in RPMs in order to install them. I'm unclear what is envolved in compiling from the source code myself. I did a general google on the topic and found some unclear... (3 Replies)
Discussion started by: Mark Ward
3 Replies

7. Linux

source code for linux

Hi , where can i get free source code for LINUX commands , OS , system calls etc. Thanks Naren (2 Replies)
Discussion started by: naren_chella
2 Replies
Login or Register to Ask a Question