From 12897fe3c2dcb77731ebbb5a0e951e3725462b28 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Sat, 23 Mar 2013 09:49:08 +0100 Subject: [PATCH] src/parallel: --load on remote machines fixed. --nice uses \nice for tcsh and remote machines with differerent path to nice. --- src/parallel | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/src/parallel b/src/parallel index b26cd3b3..da543fb4 100755 --- a/src/parallel +++ b/src/parallel @@ -2506,13 +2506,11 @@ sub loadavg { $self->{'last_loadavg_update'} = time; -e $ENV{'HOME'}."/.parallel" or mkdir $ENV{'HOME'}."/.parallel"; -e $ENV{'HOME'}."/.parallel/tmp" or mkdir $ENV{'HOME'}."/.parallel/tmp"; - my $cmd; - if($self->{'string'} eq ":") { - $cmd = "ps ax -o state,command"; - } else { - $cmd = $self->sshcommand() . " " . $self->serverlogin() . - "ps ax -o state,command"; - } + my $cmd = ""; + if($self->{'string'} ne ":") { + $cmd = $self->sshcommand() . " " . $self->serverlogin() . " "; + } + $cmd .= "ps ax -o state,command"; # As the command can take long to run if run remote # save it to a tmp file before moving it to the correct file my $file = $self->{'loadavg_file'}; @@ -4582,9 +4580,10 @@ sub replaced { } } if($opt::nice) { - # Prepend nice -n19 $SHELL -c + # Prepend \nice -n19 $SHELL -c # and quote - $self->{'replaced'} = nice() ." -n" . $opt::nice . " " + # \ before nice is needed to avoid tcsh's built-in + $self->{'replaced'} = '\nice' ." -n" . $opt::nice . " " . $ENV{SHELL}." -c " . ::shell_quote_scalar($self->{'replaced'}); } @@ -4603,22 +4602,6 @@ sub replaced { return $self->{'replaced'}; } -sub nice { - # Returns: - # path to nice - # Needed because tcsh's built-in nice does not support 'nice -n19' - if(not $Global::path_to_nice) { - $Global::path_to_nice = "nice"; - for my $n ((split/:/, $ENV{'PATH'}), "/bin", "/usr/bin") { - if(-x $n."/nice") { - $Global::path_to_nice = $n."/nice"; - last; - } - } - } - return $Global::path_to_nice; -} - sub replace_placeholders { my $self = shift; my $target = shift;