php cli command ...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dbee

    php cli command ...

    Has anyone any idea why this doesn't work ?

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

    I've also tried

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

    no luck there either ??

  • Julien CROUZET

    #2
    Re: php cli command ...

    Il se trouve que dbee a formulé :[color=blue]
    > Has anyone any idea why this doesn't work ?
    >
    > while read file ; do php -r 'urlencode($fil e);' ; done > file
    >
    > I've also tried
    >
    > cat file | php -r 'urlencode($0); ' > file
    >
    > no luck there either ??[/color]

    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
    Easy, affordable options for you to obtain the domain you want. Safe and secure shopping.



    Comment

    • dbee

      #3
      Re: php cli command ...

      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:[color=blue]
      > Il se trouve que dbee a formulé :[color=green]
      > > Has anyone any idea why this doesn't work ?
      > >
      > > while read file ; do php -r 'urlencode($fil e);' ; done > file
      > >
      > > I've also tried
      > >
      > > cat file | php -r 'urlencode($0); ' > file
      > >
      > > no luck there either ??[/color]
      >
      > 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[/color]

      Comment

      • Julien CROUZET

        #4
        Re: php cli command ...

        dbee a pensé très fort :[color=blue]
        > Julien CROUZET wrote:[color=green]
        >> Il se trouve que dbee a formulé :[color=darkred]
        >>> Has anyone any idea why this doesn't work ?
        >>>
        >>> while read file ; do php -r 'urlencode($fil e);' ; done > file
        >>>
        >>> I've also tried
        >>>
        >>> cat file | php -r 'urlencode($0); ' > file
        >>>
        >>> no luck there either ??[/color]
        >>
        >> 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 );
        >>[/color]
        > Thanks julien,
        >
        > 1) php cli only accepts single quotes I'm afraid
        >[/color]

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

        --
        Julien CROUZET - DSI Theoconcept
        julien.crouzet@/enlever ca\theoconcept. com
        Easy, affordable options for you to obtain the domain you want. Safe and secure shopping.



        Comment

        • dbee

          #5
          Re: php cli command ...

          Merci beaucoup,

          Excellent thanks julien
          Julien CROUZET wrote:[color=blue]
          > dbee a pensé très fort :[color=green]
          > > Julien CROUZET wrote:[color=darkred]
          > >> Il se trouve que dbee a formulé :
          > >>> Has anyone any idea why this doesn't work ?
          > >>>
          > >>> while read file ; do php -r 'urlencode($fil e);' ; 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 );
          > >>[/color]
          > > Thanks julien,
          > >
          > > 1) php cli only accepts single quotes I'm afraid
          > >[/color]
          >
          > $>sh
          > $>echo "encode this : %}&" | while read file ; do php -r "echo
          > urlencode('$fil e');" ; done
          > encode+this+%3A +%25%7D%26
          >
          > --
          > Julien CROUZET - DSI Theoconcept
          > julien.crouzet@/enlever ca\theoconcept. com
          > http://www.theoconcept.com[/color]

          Comment

          • Julien CROUZET

            #6
            Re: php cli command ...

            Le 21/02/2006, dbee a supposé :[color=blue]
            > Julien CROUZET wrote:[color=green]
            >> dbee a pensé très fort :[color=darkred]
            >>> 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($fil e);' ; 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
            >>>[/color]
            >>
            >> $>sh
            >> $>echo "encode this : %}&" | while read file ; do php -r "echo
            >> urlencode('$fil e');" ; done
            >> encode+this+%3A +%25%7D%26
            >>[/color]
            > Merci beaucoup,
            >
            > Excellent thanks julien[/color]

            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($_SER VER['file']);' ; done

            NULL


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

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

            Greetings,

            --
            Julien CROUZET - DSI Theoconcept
            julien.crouzet@/enlever ca\theoconcept. com
            Easy, affordable options for you to obtain the domain you want. Safe and secure shopping.



            Comment

            Working...