[PHP] Re: How to print variable name and contents
nntp.charter.net wrote: I want to write a trace procedure and call it with variable names, and I am having trouble with the syntax. My goal is to have a procedure that will echo lines such as: Trace: $myvar="the contents of $myvar My attempt that didn't work is to write a function: function my_trace($m){ echo ("\nTRACE: $m = "); eval("\$t=\"$m\";"); echo($t."\n"); } and call it with statements like: my_trace("\$my_var"); my_trace("\$_ENV[\"COMPUTERNAME\"]"); What am I doing wrong, and how should this be done? Also, should I post to a different group? Thanks, Gil Grodsky [EMAIL PROTECTED] Try this script, it works for me: $my_var = 'Hello world!'; function my_trace($m){ // pay attention to the use of single vs double quotes throughout $q = substr($m, 1); // chop off the leading '$' in the variable name @eval("global \${$q};"); // need to use global to get value of local variables into this function // also need @ to supress warning caused by brackets in superglobal variables eval("\$t = \${$q};");// assign value of orginal $m to $t echo ("TRACE: $m = $t"); // output my_trace('$my_var'); // note the use of single quotes here my_trace('$_ENV["COMPUTERNAME"]'); // note where the single quotes are used here Hope it helps, Bob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to print variable name and contents
Bob Winter wrote: nntp.charter.net wrote: I want to write a trace procedure and call it with variable names, and I am having trouble with the syntax. My goal is to have a procedure that will echo lines such as: Trace: $myvar="the contents of $myvar My attempt that didn't work is to write a function: function my_trace($m){ echo ("\nTRACE: $m = "); eval("\$t=\"$m\";"); echo($t."\n"); } and call it with statements like: my_trace("\$my_var"); my_trace("\$_ENV[\"COMPUTERNAME\"]"); What am I doing wrong, and how should this be done? Also, should I post to a different group? Thanks, Gil Grodsky [EMAIL PROTECTED] Sorry, I was missing a closing '}' in my previous post -- it should have been: $my_var = 'Hello world!'; function my_trace($m){ // pay attention to the use of single vs double quotes throughout $q = substr($m, 1); // chop off the leading '$' in the variable name @eval("global \${$q};"); // need to use global to get value of local variables into this function // also need @ to supress warning caused by brackets in superglobal variables eval("\$t = \${$q};");// assign value of orginal $m to $t echo ("TRACE: $m = $t"); // output } my_trace('$my_var'); // note the use of single quotes here my_trace('$_ENV["COMPUTERNAME"]'); // note where the single quotes are used here / Bob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: rename
Look at http://us2.php.net/manual/en/function.rename.php Mister Jack wrote: Hi, I would like to know precisely what rename do in case of error. any link for that ? I do a : @rename($old, $new), what happens if I run out of space ? is the rename just an alias for C function library ? thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Allowed memory size of
David, Perhaps your memory usage and/or memory limit is different than what you are assuming it is. If you add the following code to your script, in several places if necessary, it should help you debug it . // PRINT CURRENT MEMORY USAGE: http://us4.php.net/manual/en/function.memory-get-usage.php print 'CURRENT MEMORY USAGE = '.memory_get_usage().''; // PRINT CURRENT MEMORY LIMIT: http://us4.php.net/manual/en/function.ini-get.php print 'MEMORY LIMIT = '.ini_get('memory_limit').''; You can also set the memory limit on a per page basis // SET MEMORY LIMIT:http://us4.php.net/manual/en/function.ini-set.php $mem_limit = '128'; print "SETTING MEMORY LIMIT TO $mem_limit Megabytes"; ini_set('memory_limit', $mem_limit.'M'); //http://us4.php.net/manual/en/ini.core.php#ini.memory-limit There are a variety of limitations and restrictions to the commands noted above, be sure to read the documentation. -- Bob david forums wrote: Hello I got the following message. PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 69505726 bytes) I read on several forums to increase the size of the memory limit in php.ini. As you can wee which as already be done cause 134217728>69505726. But I still get the message. I'll like to understand and find how to do. The aim of this script is to get a big file (69MB) and to encrypt (using mcrypt). then to send it by ftp. Thanks for your helps david -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Allowed memory size of
David I don't have a definitive answer for you, but I notice that the memory size is less than twice the file size. Depending on the PHP functions you are using you could be eating up a lot of memory in the execution of the script that wouldn't necessary show up where you inserted the debugging statements. Does the script work with smaller files? Can you the memory_limit to something very high, over 220 Mb, and/or test your script with smaller files to find the threshold where the Fatal error occurs? -- Bob david forums wrote: Bob I try to run your test script. So before the file reading the memory is 125730 o, and I 'm not able to get the next text due to error display CURRENT MEMORY USAGE = 125720 PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 69505726 bytes) I tried to set the memory_limit in the script and set a default value more efficient in the php.ini That show the same error. Thanks for your helps david Le Mon, 20 Jun 2005 16:46:36 +0200, Bob Winter <[EMAIL PROTECTED]> a écrit: David, Perhaps your memory usage and/or memory limit is different than what you are assuming it is. If you add the following code to your script, in several places if necessary, it should help you debug it .// PRINT CURRENT MEMORY USAGE: http://us4.php.net/manual/en/function.memory-get-usage.php print 'CURRENT MEMORY USAGE = '.memory_get_usage().''; // PRINT CURRENT MEMORY LIMIT: http://us4.php.net/manual/en/function.ini-get.php print 'MEMORY LIMIT = '.ini_get('memory_limit').''; You can also set the memory limit on a per page basis // SET MEMORY LIMIT: http://us4.php.net/manual/en/function.ini-set.php $mem_limit = '128'; print "SETTING MEMORY LIMIT TO $mem_limit Megabytes"; ini_set('memory_limit', $mem_limit.'M'); //http://us4.php.net/manual/en/ini.core.php#ini.memory-limit There are a variety of limitations and restrictions to the commands noted above, be sure to read the documentation. -- Bob david forums wrote: Hello I got the following message. PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 69505726 bytes) I read on several forums to increase the size of the memory limit in php.ini. As you can wee which as already be done cause 134217728>69505726. But I still get the message. I'll like to understand and find how to do. The aim of this script is to get a big file (69MB) and to encrypt (using mcrypt). then to send it by ftp. Thanks for your helps david -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Allowed memory size of
David, I don't believe this to be a bug. In order to process the script, PHP needs to use additional memory resources. My guess is that while the original 69Mb file is loaded, the new encrypted file also needs to exist in memory. Glad you were able to find a solution. --Bob david forums wrote: I did it IT works with 256M memory allocated. After realising the line it shown 69505726(little more )Mo as memory usage. It's in some way really not understandable. I suppose it could be a php bug. tx david Le Tue, 21 Jun 2005 16:35:20 +0200, Bob Winter <[EMAIL PROTECTED]> a écrit: David I don't have a definitive answer for you, but I notice that the memory size is less than twice the file size. Depending on the PHP functions you are using you could be eating up a lot of memory in the execution of the script that wouldn't necessary show up where you inserted the debugging statements. Does the script work with smaller files? Can you the memory_limit to something very high, over 220 Mb, and/or test your script with smaller files to find the threshold where the Fatal error occurs? -- Bob david forums wrote: Bob I try to run your test script. So before the file reading the memory is 125730 o, and I 'm not able to get the next text due to error display CURRENT MEMORY USAGE = 125720 PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 69505726 bytes) I tried to set the memory_limit in the script and set a default value more efficient in the php.ini That show the same error. Thanks for your helps david Le Mon, 20 Jun 2005 16:46:36 +0200, Bob Winter <[EMAIL PROTECTED]> a écrit: David, Perhaps your memory usage and/or memory limit is different than what you are assuming it is. If you add the following code to your script, in several places if necessary, it should help you debug it .// PRINT CURRENT MEMORY USAGE: http://us4.php.net/manual/en/function.memory-get-usage.php print 'CURRENT MEMORY USAGE = '.memory_get_usage().''; // PRINT CURRENT MEMORY LIMIT: http://us4.php.net/manual/en/function.ini-get.php print 'MEMORY LIMIT = '.ini_get('memory_limit').''; You can also set the memory limit on a per page basis // SET MEMORY LIMIT: http://us4.php.net/manual/en/function.ini-set.php $mem_limit = '128'; print "SETTING MEMORY LIMIT TO $mem_limit Megabytes"; ini_set('memory_limit', $mem_limit.'M'); //http://us4.php.net/manual/en/ini.core.php#ini.memory-limit There are a variety of limitations and restrictions to the commands noted above, be sure to read the documentation. -- Bob david forums wrote: Hello I got the following message. PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 69505726 bytes) I read on several forums to increase the size of the memory limit in php.ini. As you can wee which as already be done cause 134217728>69505726. But I still get the message. I'll like to understand and find how to do. The aim of this script is to get a big file (69MB) and to encrypt (using mcrypt). then to send it by ftp. Thanks for your helps david -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: array_search() with preg_match?
René, This may not the most efficient method, but works: $array = array('this sky is blue', 'pencils are orange', 'I like green apples','strawberries are red'); $search = 'green'; $result = array(); foreach($array as $key1=>$value1) { if(substr_count($value1, $search)) { $result[] = $key1; } } // $result is an array containing all the keys for the values that contained the search phrase print_r($result); // or convert to string print implode(' ', $result); // or however else to need to handle the results --Bob René Fournier wrote: I need to search an array for a string, with a twist. E.g.: $array = array(0 => 'this sky is blue', 1 => 'pencils are orange', 2 => 'I like green apples', 3 => 'strawberries are red'); $key = array_search('green', $array); With the above code, nothing will be returned, but I would like it to return 2 for the key containing "green". Any suggestions? ...René -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with arrays
Mike Johnson wrote: From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Hi, I have 2 arrays: Array ( [0] => Array ( [0] => 28 [1] => Music ) [1] => Array ( [0] => 5 [1] => Books ) ) and Array ( [0] => aaa [1] => bbb ) I want to join this two array and the result must be loke this: Array ( [0] => Array ( [0] => 28 [1] => Music [2] => aaa ) [1] => Array ( [0] => 5 [1] => Books [2] => bbb ) ) Thanks in advance for your help In this specific example, I think this would work: That's not terribly flexible, though. Is this used in a more generalized sense, or is it just this specific instance? This variation of Mike's solution will allow the array keys to be non-numeric and/or non-incrementing. $value) { if(array_key_exists($key, $first_array)) { array_push($first_array[$key], $value); } else { print 'ERROR: Key '.$key.' does not exist in array $first_array.\n'; // or alternatively to add a new sub-array to $first_array // $first_array[$key] = array($value); } } ?> --Bob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: newline and pregreplace
Dotan Cohen wrote: I've got a line like this: $str=preg_replace( "-regex here-", '\n\1', $str); Which has one of two problems: If I leave the single quotes around the second argument, then it returns as \n and not a newline. If I change the single quotes to double quotes, then the info from the regex is not inserted in place of the \1. What is one to do in these situations? Dotan http://lyricslist.com/lyrics/artist_albums/273/jackson_michael.php Michael Jachson Lyrics Dotan, Try escaping the newline in your example: $str=preg_replace( "-regex here-", '\\n\1', $str); --Bob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: newline and pregreplace
Bob Winter wrote: Dotan Cohen wrote: I've got a line like this: $str=preg_replace( "-regex here-", '\n\1', $str); Which has one of two problems: If I leave the single quotes around the second argument, then it returns as \n and not a newline. If I change the single quotes to double quotes, then the info from the regex is not inserted in place of the \1. What is one to do in these situations? Dotan http://lyricslist.com/lyrics/artist_albums/273/jackson_michael.php Michael Jachson Lyrics Dotan, Try escaping the newline in your example: $str=preg_replace( "-regex here-", '\\n\1', $str); --Bob Dotan, I'd like to recant my previous post, I made the mistake of not testing my suggestion first . . . try this instead: $str=preg_replace( "-regex here-", "\n$1", $str); If you still have a problem, post the regex you are using and maybe a sample string. --Bob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Correcting contractions
Dotan Cohen wrote: On 6/25/05, Robert Cummings <[EMAIL PROTECTED]> wrote: On Fri, 2005-06-24 at 21:02, Dotan Cohen wrote: Hi friends, I've got a nice array of contractions (I've, I'd, they'll,...). My intent is to take submitted data and replace, say, every occurance of 'theyd' with 'they'd'. So far, so good. The trick is doing it if the first character is uppercase. I tried going throught the array, one by one, and doing the preg_replace twice, once for each item, and once for each item with the first letter capitalized. It wasn't very succesful, so I've been doing this: $the_lyrics=str_replace("\bid\b", "I'd", $the_lyrics); $the_lyrics=str_replace("\bi'd\b", "I'd", $the_lyrics); $the_lyrics=str_replace("\bId\b", "I'd", $the_lyrics); $the_lyrics=str_replace("\bim\b", "I'm", $the_lyrics); $the_lyrics=str_replace("\bi'm\b", "I'm", $the_lyrics); $the_lyrics=str_replace("\bIm\b", "I'm", $the_lyrics); $the_lyrics=str_replace("\bi've\b", "I've", $the_lyrics); $the_lyrics=str_replace("\bive\b", "I've", $the_lyrics); $the_lyrics=str_replace("\bIve\b", "I've", $the_lyrics); $the_lyrics=str_replace("\bi'll\b", "I'll", $the_lyrics); $the_lyrics=str_replace("\bIll\b", "I'll", $the_lyrics); $the_lyrics=str_replace("\bi\b", "I", $the_lyrics); $the_lyrics=str_replace("\byoure\b", "you're", $the_lyrics); $the_lyrics=str_replace("\bYoure\b", "You're", $the_lyrics); $the_lyrics=str_replace("\byoull\b", "you'll", $the_lyrics); $the_lyrics=str_replace("\bYoull\b", "You'll", $the_lyrics); $the_lyrics=str_replace("\byouve\b", "you've", $the_lyrics); $the_lyrics=str_replace("\bYouve\b", "You've", $the_lyrics); $the_lyrics=str_replace("\bits\b", "it's", $the_lyrics); $the_lyrics=str_replace("\bIts\b", "It's", $the_lyrics); $the_lyrics=str_replace("\bwasnt\b", "wasn't", $the_lyrics); $the_lyrics=str_replace("\bWasnt\b", "Wasn't", $the_lyrics); $the_lyrics=str_replace("\bthats\b", "that's", $the_lyrics); $the_lyrics=str_replace("\bThats\b", "That's", $the_lyrics); $the_lyrics=str_replace("\btheyre\b", "they're", $the_lyrics); $the_lyrics=str_replace("\bTheyre\b", "They're", $the_lyrics); $the_lyrics=str_replace("\btheyll\b", "they'll", $the_lyrics); $the_lyrics=str_replace("\bTheyll\b", "They'll", $the_lyrics); $the_lyrics=str_replace("\bcant\b", "can't", $the_lyrics); $the_lyrics=str_replace("\bCant\b", "Can't", $the_lyrics); $the_lyrics=str_replace("\bdidnt\b", "didn't", $the_lyrics); $the_lyrics=str_replace("\bDidnt\b", "Didn't", $the_lyrics); $the_lyrics=str_replace("\bdont\b", "don't", $the_lyrics); $the_lyrics=str_replace("\bDont\b", "Don't", $the_lyrics); $the_lyrics=str_replace("\bdoesnt\b", "doesn't", $the_lyrics); $the_lyrics=str_replace("\bDoesnt\b", "Doesn't", $the_lyrics); $the_lyrics=str_replace("\bweve\b", "we've", $the_lyrics); $the_lyrics=str_replace("\bWeve\b", "We've", $the_lyrics); Which, as you can see, is not exactly optimized code. How would someone more professional than myself go about this? I was thinking about maybe a two-dimentional array, but stopped short to consult with you guys first. string_replace() supports taking two arrays from which to retrieve the needles and the replacements so that you only need to invoke the function once. This will speed things up considerably. On that note you have a couple of bugs... "its" is a valid word for possession (its woodwork is exquisite). 'Ill" is also valid (Ill beset by fortune). Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' Ill I knew about, its I didn't. I didn't mean to put ill in there... Should I enter each contraction twice (for the capitalization), or should I try to do something smart so that the capitalization will happen automatically. The 'I' contractions are special, I will deal with those seperatly. Dotan, Your task intrigued me, so I put together a function that will help process your data: "; print "Corrected string: $result"; ?> --Bob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] shell expansion (globbing) from inside php cli script
Brian, Can you post more of the script? --Bob Brian V Bonini wrote: On Mon, 27 Jun 2005, [ISO-8859-1] Andr? Medeiros wrote: $cmd = 'scp ' . $user . '@stagingcws.' . $tld . ':' . $directory/{' . $files . '} ' . $tmp_dir . '/'; That should work On 6/27/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Can not make this work inside a php script. Have tried several variations: $cmd = "scp [EMAIL PROTECTED]:$directory/\{$files} $tmp_dir/."; $cmd = "scp [EMAIL PROTECTED]:$directory/" . '{' . $files . '} ' . "$tmp_dir/."; etc... I can echo out the command and get a well formed command, i.e. one that will execute from a command prompt, but when I try to exec() $cmd from within the script the globbing is taken literally. No, I already tried it that way too. I guess I should mention this is a cli script if that matters. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Files
Chris, He's my take on your problem, I have used a few different functions but followed the same pattern as your original script. Check out http://www.php.net/manual/en/ to get the details on the ones you don't understand. I have not included error checking. This example works successfully on my system. --Bob \n"; // Notify the user on screen if the send was succesfull if(mail($email, $subject, $message, $headers)) { print "Mail sent successfully to $email"; } else { print "Mail not sent to $email"; } } } } } if(!$cnt) { print 'No matches in files.'; } ?> Chris Grigor wrote: Hey all, I am having a bash at working with flat files. What I am trying to achieve is the following There are 2 files with info in them, file1 has id,email and file2 has id,filename what I am trying to achieve is open up file1 get the id and email then open file2 and match the id of file1 to id of file2, then if succesful send a mail with the filename in file2. Maybe have a look at the code... $recp_list = fopen("mail_group_list.txt", "r"); while(!feof($recp_list)) { $line = fgets($recp_list, 255); $line = chop($line); $split = explode(",", $line); $id = $split[0]; $email = $split[1]; // time to mail. if ($email != "") { $group_list = fopen("file_group_list.txt", "r"); while(!feof($group_list)) { $groupline = fgets($group_list, 255); $groupline = chop($groupline); $groupsplit = explode(",", $groupline); $groupid = $groupsplit[0]; $groupFileName = $groupsplit[1]; if($groupid = $id) { // start mailing $fromname = "Test Mailer"; $fromaddress = "[EMAIL PROTECTED]"; $subject = "Test mail"; $message = "Test message $groupFileName"; $headers = "From: \"".$fromname."\" <".$fromaddress.">\n"; // Notify the user on screen if the send was succesfull if(mail($email, $subject, $message, $headers)) { print "Mail sent successfully to $email"; } else { print "Mail not sent to $email"; } }#end if groupid = id }#end while group list }#end if email }#end while email !="" ?> So thats the mail.php mail_list_group.txt looks like this 1,test@test.com 5,[EMAIL PROTECTED] 7,test@test.com file_group_list.txt looks like this 2,filename1.doc 3,filename2.doc 4,filename3.doc Any help on this would be great ! Cheers Chris PS the formatting might come out all wrong as its mailed from a web account. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] shell expansion (globbing) from inside php cli script
Brian, The format of your string that works for me is : $cmd = "scp [EMAIL PROTECTED]:$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 === END Hope this solves your problem. --Bob Brian V Bonini wrote: if($confirm == "s") { //if staging suck the files down to temp local dir first $cmd = "scp [EMAIL PROTECTED]:$directory/{{$files}} $tmp_dir/."; echo $cmd . "\n\n"; exec($cmd, $output, $err); //shell_exec($cmd); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] shell expansion (globbing) from inside php cli script
Brian V Bonini wrote: 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 [EMAIL PROTECTED]:/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 Brian, The script works for me, I should have included the screen input/output, which now follows: [EMAIL PROTECTED] ~ 1]# ls -l /tmp/file* ## Location of original files -rwxrwxrwx 1 root root 5 Jun 28 22:15 /tmp/file_A -rwxrwxrwx 1 root root 5 Jun 28 22:15 /tmp/file_B -rwxrwxrwx 1 root root 5 Jun 28 22:15 /tmp/file_C [EMAIL PROTECTED] ~ 2]# [EMAIL PROTECTED] ~ 2]# ls -l /tmp/test/## Location of copied files total 0 [EMAIL PROTECTED] ~ 3]# [EMAIL PROTECTED] ~ 3]# /var/www/html/test_script01.php ## Executing my test script [EMAIL PROTECTED]'s password: string: scp [EMAIL PROTECTED]:/tmp/{file_A,file_B,file_C\} /tmp/test status:0 Array ( ) [EMAIL PROTECTED] ~ 4]# [EMAIL PROTECTED] ~ 4]# ls -l /tmp/test/## Files have been copied total 12 -rwxr-xr-x 1 root root 5 Jun 29 09:36 file_A -rwxr-xr-x 1 root root 5 Jun 29 09:36 file_B -rwxr-xr-x 1 root root 5 Jun 29 09:36 file_C [EMAIL PROTECTED] ~ 5]# [EMAIL PROTECTED] ~ 5]# php -v ## My PHP version PHP 4.3.11 (cli) (built: May 31 2005 11:29:57) Copyright (c) 1997-2004 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies [EMAIL PROTECTED] ~ 6]# Also I am running on Fedora Core 1. While running my tests I found that any whitespace within the brackets would cause a failure. If you run your script with "scp -v " you can see each file being copied (or not copied). Here's my output, NOTICE THAT THE $cmd STRING ECHOED BY THE COMMAND LINE SHELL IS DIFFERENT FROM THE PHP SCRIPT'S ECHO Hope there is something here that helps you. -- Bob [EMAIL PROTECTED] ~ 6]# /var/www/html/test_script01.php ## With scp -v flag Executing: program /usr/local/bin/ssh host bmw.com, user root, command scp -v -f /tmp/{file_A,file_B,file_C} OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003 debug1: Reading configuration data /usr/local/etc/ssh_config debug1: Applying options for * debug1: Connecting to bmw.com [127.0.0.1] port 22. debug1: Connection established. debug1: permanently_set_uid: 0/0 debug1: identity file /root/.ssh/identity type -1 debug1: identity file /root/.ssh/id_rsa type 1 debug1: identity file /root/.ssh/id_dsa type -1 debug1: Remote protocol version 1.99, remote software version OpenSSH_3.9p1 debug1: match: OpenSSH_3.9p1 pat OpenSSH* debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_3.9p1 debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client aes128-cbc hmac-md5 none debug1: kex: client->server aes128-cbc hmac-md5 none debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP debug1: SSH2_MSG_KEX_DH_GEX_INIT sent debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY debug1: Host 'bmw.com' is known and matches the RSA host key. debug1: Found key in /root/.ssh/known_hosts:17 debug1: ssh_rsa_verify: signature correct debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey,password,keyboard-interactive debug1: Next authentication method: publickey debug1: Trying private key: /root/.ssh/identity debug1: Offering public key: /root/.ssh/id_rsa debug1: Authentications that can continue: publickey,password,keyboard-interactive debug1: Trying private key: /root/.ssh/id_dsa debug1: Next authentication method: keyboard-interactive debug1: Authentications that can continue: publickey,password,keyboard-interactive debug1: Next authentication method: password [EMAIL PROTECTED]'s password: debug1: Authentication succeeded (password). debug1: channel 0: new [client-session] debug1: Entering interactive session. debug1: Sending command: scp -v -f /tmp/{file_A,file_B,file_C} Sending file modes: C0777 5 file_A Sink: C0777 5 file_A Sending file modes: C0777 5 file_B Sink: C0777 5 file_B Sending file modes: C0777 5 file_C Sink: C0777 5 file_C debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 debug1: channel 0: free: client-session, nchannels 1 debug1: fd 0 clearing O_NONBLOCK debug1: fd 1 clearing O_NONBLOCK debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 0.3 seconds debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0 debug1: Exit status 0 string: scp -v [EMAIL PROTECTED]:/tmp/{file_A,fil
Re: [PHP] shell expansion (globbing) from inside php cli script
Brian, Is "/www/files/services/" the correct relative path?? You could try using the absolute path to see if it fixes the problem. Also, and maybe more significant, I use tcsh . . . if you use bash this could be the conflict. I see that the echo of the $cmd string from PHP is missing the '\}' that is in my test. -- Bob Brian V Bonini wrote: Hmmm, this simply does not work for me. Maybe something with my version of php or ssh.. I'm at a loss.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php