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

From: Date: Wed, 29 Jun 2005 13:14:13 +0000
Subject: Re: shell expansion (globbing) from inside php cli script
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-217813@lists.php.net to get a copy of this message
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@foobar.com:/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

« previous php.general (#217813) next »