Posted by lisa.rae on September 5, 2012 at 7:13pm
I wrote an install script to set up a sandbox site on my local machine using a drush make file and some scripted commands.
The gist of the script is:
#!/usr/bin/env drush
$a = drush_get_arguments();
$current_directory = getcwd();
$profiles = substr($a[1], 0, strlen($a[1])-15) . 'standard.make';
if(file_exists($current_directory . '/installsettings.php')) {
require_once($current_directory . '/installsettings.php');
}
drush_print("Time to prepare our site install...");
if(!file_exists('logs')) {
drush_op_system('mkdir logs');
}
if(!file_exists('public_html')) {
(more code here......)
}
So, any ideas on fixing the error? Drush is in the environment path, drush is executable from the command line, php is in the environment path and executable from the command line as well
Comments
You are lucky that the "\r"
You are lucky that the "\r" was rendered in the error message above; this has happened to me before, and it can be deathly difficult to track down. The problem you are having is that your line endings in that text file are all CR LF ('\r', '\n'). The editor does not show you the \r, but Bash sees the \r at the end of "drush" and treats it as part of the line. Bash is, then, literally looking for a file called "drush\r" to execute. Get rid of those invisible \r characters at the end of each line, and your script should work.
On a different note, you might want to investigate converting your script into a full Drush command. See 'drush topic' for an example. Once you start using options and arguments in your script, it usually becomes worthwhile to make a command.
Finally, you might also want to look into the Drush 'qd' command; might make a good addition/compliment to your script. You can call it from php via 'drush_invoke_process("@self", "qd", array([args]), array([options]));'
Thank you, that was exactly the problem
A coworker edited the script file with an editor that inserted CR at the end of each line.
Thank you.