Open MPI logo

MTT Devel Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all MTT Devel mailing list

Subject: Re: [MTT devel] [MTT svn] svn:mtt-svn r1319
From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2009-09-24 09:02:30


I'm not sure this is right.

The DoCommand.pm sub added ":\n" to the beginning to force the Bourne
shell interpreter. This is necessary for some cases where an
interpreter is not otherwise specified.

I see why you did it -- you want the ability to add your own
interpreter in &shell_script(). Why not either make a parameter to
add the ":\n" or not, or better yet, have DoCommand.pm analyze the
beginning of the string and if it contains "^:\n" or "^#!", then don't
add anything. But if it doesn't contain either of those, then prefix
it with ":\n".

How does that sound?

Also, is "&shell_script()" a good name? If you can specify your own
interpreter, it might not be a shell script. How about &executable()?

On Sep 24, 2009, at 8:06 AM, miked_at_[hidden] wrote:

> Author: miked
> Date: 2009-09-24 08:06:04 EDT (Thu, 24 Sep 2009)
> New Revision: 1319
> URL: https://svn.open-mpi.org/trac/mtt/changeset/1319
>
> Log:
> bug fix: CmdScript() - no need to add extra chars "\n:" to the start
> of shell script file
> new funclet: shell_script(section,param)
>
>
> Text files modified:
> trunk/lib/MTT/DoCommand.pm | 2 +-
> trunk/lib/MTT/Values/Functions.pm | 19 +++++++++++++++++++
> 2 files changed, 20 insertions(+), 1 deletions(-)
>
> Modified: trunk/lib/MTT/DoCommand.pm
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- trunk/lib/MTT/DoCommand.pm (original)
> +++ trunk/lib/MTT/DoCommand.pm 2009-09-24 08:06:04 EDT (Thu, 24 Sep
> 2009)
> @@ -797,7 +797,7 @@
> $cmds =~ s/\"$//
> if ($cmds =~ s/^\"//);
>
> - print $fh ":\n$cmds\n";
> + print $fh "$cmds\n";
> close($fh);
> chmod(0700, $filename);
>
>
> Modified: trunk/lib/MTT/Values/Functions.pm
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- trunk/lib/MTT/Values/Functions.pm (original)
> +++ trunk/lib/MTT/Values/Functions.pm 2009-09-24 08:06:04 EDT (Thu,
> 24 Sep 2009)
> @@ -3026,4 +3026,23 @@
> return md5_hex($str);
> }
>
> +# Run shell commands as a script, i.e
> +#
> +# [mtt]
> +# myscript=<<EOT
> +# #!/bin/sh
> +# pwd
> +# ls
> +# EOT
> +# on_stop=&shell_script("mtt",myscript)
> +#
> +#
> +
> +sub shell_script {
> + my ($cmd_section, $cmd_param) = @_;
> + my $cmd = &get_ini_val($cmd_section, $cmd_param);
> + my $x = MTT::DoCommand::CmdScript(1, $cmd);
> + return $x->{result_stdout};
> +}
> +
> 1;
> _______________________________________________
> mtt-svn mailing list
> mtt-svn_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/mtt-svn

-- 
Jeff Squyres
jsquyres_at_[hidden]