473,503 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

shell script + php

I'm writing a shell script and inside of it I have variable that I
want to pass to php, but for some reason it isn't working... can
someone help me? here is example

#!/bin/sh

i=127.0.0.1

php -r 'geoip_country_name_by_name($i);'

echo $?

php part works in shell if i use actual value from variable and not
variable itself
Jul 25 '08 #1
3 1450
alexus escribió:
I'm writing a shell script and inside of it I have variable that I
want to pass to php, but for some reason it isn't working... can
someone help me? here is example

#!/bin/sh

i=127.0.0.1

php -r 'geoip_country_name_by_name($i);'
In bash, single quotes mean "do not parse variables". Try double quotes.
Also, PHP require quotes around strings.

--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Jul 25 '08 #2
Ãlvaro G. Vicario wrote:
alexus escribi�:
I'm writing a shell script and inside of it I have variable that I
want to pass to php, but for some reason it isn't working... can
someone help me? here is example

#!/bin/sh

i=127.0.0.1

php -r 'geoip_country_name_by_name($i);'

In bash, single quotes mean "do not parse variables". Try double quotes.
Also, PHP require quotes around strings.
Alternatively tell PHP where to find the variable:

php -r 'geoip_country_name_by_name($_ENV[\'i\']);'

C.
Jul 25 '08 #3
On Jul 25, 3:25*am, "Álvaro G. Vicario"
<alvaroNOSPAMTHA...@demogracia.comwrote:
alexus escribió:
I'm writing a shell script and inside of it I have variable that I
want to pass to php, but for some reason it isn't working... can
someone help me? here is example
#!/bin/sh
i=127.0.0.1
php -r 'geoip_country_name_by_name($i);'

In bash, single quotes mean "do not parse variables". Try double quotes.
Also, PHP require quotes around strings.

--
--http://alvaro.es- Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web:http://bits.demogracia.com
-- Mi web de humor al baño María:http://www.demogracia.com
--
thanks! that worked!
Jul 28 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5653
by: Mohsin | last post by:
Hi all, I have a perl program which makes a user exit to the O/S (unix, solaris) to issue a O/S command. I know that the shell it invokes is NOT a korn shell, because I captured the shell info...
3
3691
by: FPGA05 | last post by:
Hello All, I am developing a small application in which I would need a C++ application to read the output from a shell script. A shell script keeps looking for user inputs and once the user...
6
8461
by: Sanket80 | last post by:
Hi, I have one shell script which runs a report and sends the output to user. The shell script has some queries written in it in SQL and hence when I execute a shell script via a concurrent...
9
78177
by: sohan | last post by:
Hi, I want to know how to connect and execute a db2 query from inside a UNIX shell script. Details: We have a unix shell script. We need to execute multiple db2 sql queries from this shell...
3
5437
by: telduivel | last post by:
Can someone please help me with this: I have a python script, that at some point calls a linux bash script (.sh). Starting the shell script is the last thing my python script needs to do, so I...
2
3466
by: ellennolan | last post by:
Hello, I wonder if anyone can help with calling external shell script in c++. Basically, in the shellscript, I want to pass src, dst, md5. If the src's md5 matches md5 given, it will be link to...
5
2143
by: Hul Tytus | last post by:
comp.lang.c c programs & shell conditionals How is a unix shell script made to respond to the value returned by a program compiled from c code? The shell script below is my current effort,...
5
5066
by: inetquestion | last post by:
I am looking for a web interface for shell commands or shell scripts. Does anyone know of any exexisting php scripts which would solve this requirement? PHP form accepts input from a user, then...
7
6204
by: Samuel A. Falvo II | last post by:
I have a shell script script.sh that launches a Java process in the background using the &-operator, like so: #!/bin/bash java ... arguments here ... & In my Python code, I want to invoke...
4
34268
by: devi thapa | last post by:
Hi, I am executing a python script in a shell script. The python script actually returns a value. So, can I get the return value in a shell script? If yes, then help me out. Regards, Devi
0
7194
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7070
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6976
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5566
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
372
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.