473,396 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Please help me on..passing a variable from a file using unix to a php file..

28
Hello there,

I have to pass a variable from unix as an input to a php file.
The syntax i used is
Expand|Select|Wrap|Line Numbers
  1. var1="SUCCESS"
  2. report_errors.php var1
  3.  
Now report_errors is not being executed and the php start symbols "<?" etc all are being thrown as syntax errors.I dont have any idea why this is happening with php scripts on UNIX platform.Can anybody please help me with this and come up with a solution?
May 29 '07 #1
1 1203
prn
254 Expert 100+
I have to admit that I'm not particularly familiar with php, but I have a pretty good guess as to what the problem is.

You moved this from windows, right? Under windows, the filename extension tells the system how to interpret the file contents. Under unix/linux, the filename extension is just to remind you of what's in it. the system pays it no attention.

If you are going to run a script (any language) on a unix/linux system, invoked by just using its name, then the first line of the script needs to tell the OS/shell what interpreter to use, so a php script needs:
Expand|Select|Wrap|Line Numbers
  1. #! /usr/bin/php
as its first line.

Alternatively, you could invoke the script with
Expand|Select|Wrap|Line Numbers
  1. php report_errors.php
BTW, if your script refers to an environmental variable for its data, you don't need to both set the variable and pass it on the command line. If it refers to "VAR1" then you should be able to omit it from the command line. If it refers to whatever was passed to it, then you can equally well invoke the script with
Expand|Select|Wrap|Line Numbers
  1. report_errors.php "SUCCESS"
HTH,
Paul
May 29 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Mike M | last post by:
Is it possible? In the parent process, I have a socket that binds, listens and then accepts new connections (which creates new sockets in the process). I want to be able to pass some of these new...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
6
by: JLK | last post by:
I'm having a bit of a time with the following code. I can script this real easy in Bash but I'm trying to practice my C++: ******************************************************* #include...
3
by: Guru | last post by:
Hi , I tried the following 4 line of code and answer is what I never expected.I ran the code using C++ compiler(MS-Studio .net 03) also in Unix env.In fact the on Unix i got the correct (or...
28
by: Christian | last post by:
Another question from a not even newbie: In Unix you can set an environment variable with the command export PYTHONPATH but I would like to set the variable from at .py script. So my question...
4
by: hello smith | last post by:
I have a lot of functions that add values to an array. They alos update a global variable of type int. Currently, I use a global variable to hold this array. All functions access this array...
14
by: Robin Tucker | last post by:
Although I've been working on this project for 8 months now, I'm still not sure of the difference between ByVal and ByRef. As most objects in VB are reference types, passing ByVal I've discovered...
4
by: Warren Sirota | last post by:
Hi, Please let me know if I am interpreting this correctly. I've done a little testing of the difference between passing parameters byVal and byRef, and the results were slightly non-intuitive,...
2
by: luis | last post by:
I'm using ctypes to call a fortran dll from python. I have no problems passing integer and double arryas, but I have an error with str arrys. For example: ..... StringVector = c_char_p *...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.