LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 05-18-2009, 01:53 PM   #1
eco
Member
 
Registered: May 2006
Location: BE
Distribution: Debian/Gentoo
Posts: 412

Rep: Reputation: 48
Post bash result to PHP


Hi all,

I was wondering if any of you had an idea on how to do the following:

Code:
for i in `whatever the result is`; do
   php thePhpScript.php $i
done
so what I am trying to do is send the result of the for loop as a variable (equivalent to $1 in bash) to my PHP program.

Can this be done?
 
Old 05-18-2009, 02:47 PM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,453

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
In a PHP script the first argument is
Code:
$argv[1]
whereas $argv[0] is the name of the script itself.
 
Old 05-18-2009, 03:33 PM   #3
eco
Member
 
Registered: May 2006
Location: BE
Distribution: Debian/Gentoo
Posts: 412

Original Poster
Rep: Reputation: 48
Fab, seems to get the bash variable... now I can have fun trying to use it properly

Thanks mucho!
 
Old 05-18-2009, 06:50 PM   #4
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 240Reputation: 240Reputation: 240
why not gather everything into a variable, then pass to php once...?
Code:
php phpscript.php $whatever
 
  


Reply

Tags
bash, php


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[bash] how to put nslookup result next to ip in file kriezo Programming 5 02-25-2008 12:48 AM
How do I output the result of a query in php? orfiyus Programming 0 07-19-2007 02:33 PM
bash script: how to assign an output (not the result) to a variable? Singing Banzo Programming 8 10-01-2006 06:29 PM
cannot export result from awk into a variable in a bash script Emmanuel_uk Linux - Newbie 4 03-07-2005 01:54 AM
BASH Command Result redhatnoob Programming 2 08-19-2004 06:25 PM


All times are GMT -5. The time now is 07:38 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration