55
55
return (&get_base_path () . "/backup");
58
# Give a command, and it will put in C locale, some sane PATH values and find
58
# Give a command, and it will put in C locale and find
59
59
# the program to run in the path. Redirects stderr to null.
63
my ($tool_name, @argline, $command, $tool_path);
65
($tool_name, @argline) = split("[ \t]+", $cmd);
67
$tool_path = &locate_tool ($tool_name);
68
return -1 if ($tool_path eq "");
70
$command = "$tool_path @argline";
71
# Do not escape args, it's reasonable
72
# to assume they're already escaped
73
#$command =~ s/\"/\\\"/g;
82
my $command = &do_get_cmd_path ($cmd);
64
my ($tool_name, @argline) = split("[ \t]+", $cmd);
65
my $tool_path = &locate_tool ($tool_name);
66
return -1 if ($tool_path eq "");
84
return -1 if ($command == -1);
85
return ("LC_ALL=C PATH=\$PATH:/sbin:/usr/sbin $command 2> /dev/null");
68
$command = "$tool_path @argline";
69
return ("LC_ALL=C $command 2> /dev/null");
88
72
# necessary for some programs that output info through stderr
764
748
# --- Command-line utilities --- #
767
# &run (<command line>)
751
# &run_full (<in background>, <command>, <array of arguments>)
769
# Assumes the first word on the command line is the command-line utility
753
# Takes a boolean indicating whether to run the program in the background,
754
# an array containing a command to run and the arguments to pass.
755
# Assumes the first word in the array is the command-line utility
770
756
# to run, and tries to locate it, replacing it with its full path. The path
771
757
# is cached in a hash, to avoid searching for it repeatedly. Output
772
758
# redirection is appended, to make the utility perfectly silent. The
773
# preprocessed command line is run, and its exit value is returned.
759
# preprocessed command line is run, and its exit value is returned,
760
# or -1 on failure. When run in the background, 0 is returned if
761
# the fork did succeed, disregarding possible failure of exec().
775
# Example: "mkswap /dev/hda3" -> 'PATH=$PATH:/sbin:/usr/sbin /sbin/mkswap /dev/hda3 2>/dev/null >/dev/null'.
779
my ($cmd, $background) = @_;
780
my ($command, $tool_name, $tool_path, @argline);
766
my ($background, $cmd, @arguments) = @_;
767
my ($command, $tool_name, $tool_path, $pid);
782
769
&Utils::Report::enter ();
784
$command = &get_cmd_path ($cmd);
771
$tool_path = &locate_tool ($cmd);
772
return -1 if ($tool_path eq "");
785
773
return -1 if $command == -1;
786
$command .= " > /dev/null";
787
$command .= " &" if $background;
789
&Utils::Report::do_report ("file_run", $command);
775
$command = join (" ", ($tool_path, @arguments));
776
&Utils::Report::do_report ("file_run_full", $command);
790
777
&Utils::Report::leave ();
781
return -1 if (!defined $pid);
785
$ENV{"LC_ALL"} = "C";
786
open (STDOUT, "/dev/null");
787
open (STDERR, "/dev/null");
788
exec ($tool_path, @arguments);
792
# If no error has occurred so far, assume success,
793
# ignoring the future return value
794
return 0 if ($background);
792
798
# As documented in perlfunc, divide by 256.
793
return (system ($command) / 256);
802
# Simple wrappers calling &run_full() with the right background parameter
805
return &run_full (1, @_);
800
return &run ($cmd, 1);
810
return &run_full (0, @_);
803
813
# &gst_file_locate_tool