473,386 Members | 1,757 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,386 software developers and data experts.

php cli command ...

Has anyone any idea why this doesn't work ?

while read file ; do php -r 'urlencode($file);' ; done > file

I've also tried

cat file | php -r 'urlencode($0);' > file

no luck there either ??

Feb 21 '06 #1
5 1437
Il se trouve que dbee a formulé :
Has anyone any idea why this doesn't work ?

while read file ; do php -r 'urlencode($file);' ; done > file

I've also tried

cat file | php -r 'urlencode($0);' > file

no luck there either ??


1°) This should give you a trick :

$> while read file ; do echo '$file'; done
test
$file

$> while read file ; do echo "$file"; done
test
test

$variables are not interpreted in a single quote context, it does
in a DOUBLE quotes one (like in PHP).
2°) urlencode($file) returns a string, it does not output anything,
echo does.
=> echo urlencode($file);

Still no luck ?

--
Julien CROUZET - DSI Theoconcept
julien.crouzet@/enlever ca\theoconcept.com
http://www.theoconcept.com
Feb 21 '06 #2
Thanks julien,

1) php cli only accepts single quotes I'm afraid. I am aware of the
difference between single and double quotes though.

2) ya, I should have included echo there. I have tried this equation
numerous ways and have had absolutely no luck. I think the problem is
getting php to interpret a bash value.

But I can't even seem to get the read function to work here...

Thanks anyway though,
Julien CROUZET wrote:
Il se trouve que dbee a formulé :
Has anyone any idea why this doesn't work ?

while read file ; do php -r 'urlencode($file);' ; done > file

I've also tried

cat file | php -r 'urlencode($0);' > file

no luck there either ??


1°) This should give you a trick :

$> while read file ; do echo '$file'; done
test
$file

$> while read file ; do echo "$file"; done
test
test

$variables are not interpreted in a single quote context, it does
in a DOUBLE quotes one (like in PHP).
2°) urlencode($file) returns a string, it does not output anything,
echo does.
=> echo urlencode($file);

Still no luck ?

--
Julien CROUZET - DSI Theoconcept
julien.crouzet@/enlever ca\theoconcept.com
http://www.theoconcept.com


Feb 21 '06 #3
dbee a pensé très fort :
Julien CROUZET wrote:
Il se trouve que dbee a formulé :
Has anyone any idea why this doesn't work ?

while read file ; do php -r 'urlencode($file);' ; done > file

I've also tried

cat file | php -r 'urlencode($0);' > file

no luck there either ??


1°) This should give you a trick :

$> while read file ; do echo '$file'; done
test
$file

$> while read file ; do echo "$file"; done
test
test

$variables are not interpreted in a single quote context, it does
in a DOUBLE quotes one (like in PHP).
2°) urlencode($file) returns a string, it does not output anything,
echo does.
=> echo urlencode($file);

Thanks julien,

1) php cli only accepts single quotes I'm afraid


$>sh
$>echo "encode this : %}&" | while read file ; do php -r "echo
urlencode('$file');" ; done
encode+this+%3A+%25%7D%26

--
Julien CROUZET - DSI Theoconcept
julien.crouzet@/enlever ca\theoconcept.com
http://www.theoconcept.com
Feb 21 '06 #4
Merci beaucoup,

Excellent thanks julien
Julien CROUZET wrote:
dbee a pensé très fort :
Julien CROUZET wrote:
Il se trouve que dbee a formulé :
Has anyone any idea why this doesn't work ?

while read file ; do php -r 'urlencode($file);' ; done > file

I've also tried

cat file | php -r 'urlencode($0);' > file

no luck there either ??

1°) This should give you a trick :

$> while read file ; do echo '$file'; done
test
$file

$> while read file ; do echo "$file"; done
test
test

$variables are not interpreted in a single quote context, it does
in a DOUBLE quotes one (like in PHP).
2°) urlencode($file) returns a string, it does not output anything,
echo does.
=> echo urlencode($file);

Thanks julien,

1) php cli only accepts single quotes I'm afraid


$>sh
$>echo "encode this : %}&" | while read file ; do php -r "echo
urlencode('$file');" ; done
encode+this+%3A+%25%7D%26

--
Julien CROUZET - DSI Theoconcept
julien.crouzet@/enlever ca\theoconcept.com
http://www.theoconcept.com


Feb 21 '06 #5
Le 21/02/2006, dbee a supposé :
Julien CROUZET wrote:
dbee a pensé très fort :
Julien CROUZET wrote:
Il se trouve que dbee a formulé :
> Has anyone any idea why this doesn't work ?
>
> while read file ; do php -r 'urlencode($file);' ; done > file
>
> I've also tried
>
> cat file | php -r 'urlencode($0);' > file
>
> no luck there either ??

1°) This should give you a trick :

$> while read file ; do echo '$file'; done
test
$file

$> while read file ; do echo "$file"; done
test
test

$variables are not interpreted in a single quote context, it does
in a DOUBLE quotes one (like in PHP).
2°) urlencode($file) returns a string, it does not output anything,
echo does.
=> echo urlencode($file);

Thanks julien,

1) php cli only accepts single quotes I'm afraid


$>sh
$>echo "encode this : %}&" | while read file ; do php -r "echo
urlencode('$file');" ; done
encode+this+%3A+%25%7D%26

Merci beaucoup,

Excellent thanks julien


YW.

In addition, if what you searched was how to SPECIFICALLY grep a shell
variable from PHP when run as CLI ; you NEED to export(builtin) it,
else your shell won't pass it in the **environ while executing php
binary.
Here is a (dummy) example :

$>echo "encode this : %}&" | while read file ; do php -r
'var_dump($_SERVER['file']);' ; done

NULL
$>echo "encode this : %}&" | while read file ; do export file && php -r
'var_dump($_SERVER['file']);' ; done

string(17) "encode this : %}&"

Greetings,

--
Julien CROUZET - DSI Theoconcept
julien.crouzet@/enlever ca\theoconcept.com
http://www.theoconcept.com
Feb 21 '06 #6

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

Similar topics

1
by: TEK | last post by:
Hello I'm wondering if anyone out there might give some input/suggestions/viewpoints around the Command pattern. In my case, the number one priority for using the pattern is undo support. Some...
8
by: Siemel Naran | last post by:
Hi. I'm writing a command shell that reads commands from standard input. At this point I have the command in a std::string. Now I want to execute this command in the shell. From the Borland...
2
by: Chris Bolus | last post by:
I'm a teacher using MS Access on an RMConnect 2.4 network. On some workstations both I and my students sometimes get an error message when attempting to insert a command button on a form which...
2
by: micahstrasser | last post by:
I have been trying for days to send a command to the command prompt through the shell() function in vb.net. For some reason it is not working. Here is the code: Private Sub Button1_Click(ByVal...
34
by: Roman Mashak | last post by:
Hello, All! I'm implementing simple CLI (flat model, no tree-style menu etc.). Command line looks like this: <command> <param1> <param2> ... <paramN> (where N=1..4) And idea is pretty simple: ...
13
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple...
0
by: czerwww | last post by:
Can someone please help me? I have class for database connection and I need set command.commandTimeout. How can I do that? Code: Imports System.Data.SqlClient Imports System.Data Public Class...
3
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
51
by: Ojas | last post by:
Hi!, I just out of curiosity want to know how top detect the client side application under which the script is getting run. I mean to ask the how to know whether the script is running under...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.