Re: shell expansion (globbing) from inside php cli script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 28 Jun 2005, Bob Winter wrote:

> Brian,
>
> The format of your string that works for me is :
>
>     $cmd = "scp $user@stagingcws.$tld:$directory/\{$files\}  $tmp_dir";
>
> $files must be a comma separated string with NO SPACES.
>
> Here is my complete test script for your review:
> ====  START  =====
> #!/usr/bin/php
> <?php
>
> $file1 = 'file_A';
> $file2 = 'file_B';
> $file3 = 'file_C';
> $files = "$file1,$file2,$file3";
> $directory = '/tmp';
> $user = 'root';
> $tld = 'com';
> $tmp_dir = '/tmp/test';
> $cmd = "scp $user@bmw.$tld:$directory/\{$files\}  $tmp_dir";
>
> exec($cmd, $output, $err);
>
> echo "string: $cmd \n";
> echo "status:$err \n";
> print_r($output);
> ?>
> === END ====
>

I tried that too. I get '/{a,s,d,f\}' in the string if I use it that way.
Are you saying that you were able to do a succesful transfer using the
above? I can output a string that SHOULD work, e.g. "scp
joe@xxxxxxxxxx:/dir/{file1,file2,file3} /dir/." but when run from within a
php script it does not expand the stuff inside the braces. Instead it's
looking for a file literally named '{file1,file2,file3}' rather than
/dir/file1, /dir/file2, /dir/file3, etc. If you just echo the string it
will appear well formed, but try to actually use it and it will not work,
at least not for me.

-Brian

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux