Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / bin / ACEutils.pm
blob7b086849cb08cc635a328c89256696a2810ec0ea
2 require Process;
3 $EXEPREFIX = ".".$DIR_SEPARATOR;
4 $TARGETHOSTNAME = "localhost";
6 package ACE;
8 sub CheckForExeDir
10 for($i = 0; $i <= $#ARGV; $i++) {
11 if ($ARGV[$i] eq '-ExeSubDir') {
12 if (defined $ARGV[$i + 1]) {
13 $::EXEPREFIX = $ARGV[$i + 1].$::DIR_SEPARATOR;
15 else {
16 print STDERR "You must pass a directory with ExeSubDir\n";
17 exit(1);
19 splice(@ARGV, $i, 2);
25 ### Check and remove, but don't actually use
26 sub CheckForConfig
28 for($i = 0; $i <= $#ARGV;) {
29 if ($ARGV[$i] eq '-Config') {
30 if (!defined $ARGV[$i + 1]) {
31 print STDERR "You must pass a configuration with Config\n";
32 exit(1);
34 splice(@ARGV, $i, 2);
35 } else {
36 $i++;
41 sub checkForTarget
43 my($cwd) = shift;
45 for($i = 0; $i <= $#ARGV; $i++) {
46 if ($ARGV[$i] eq '-chorus') {
47 if (defined $ARGV[$i + 1]) {
48 $::TARGETHOSTNAME = $ARGV[$i + 1];
49 $::EXEPREFIX = "rsh $::TARGETHOSTNAME arun $cwd$::DIR_SEPARATOR";
51 else {
52 print STDERR "The -chorus option requires " .
53 "the hostname of the target\n";
54 exit(1);
56 splice(@ARGV, $i, 2);
57 # Don't break from the loop just in case there
58 # is an accidental duplication of the -chorus option
64 # Returns a unique id, uid for unix, last digit of IP for NT
65 sub uniqueid
67 if ($^O eq "MSWin32")
69 my $uid = 1;
71 open (IPNUM, "ipconfig|") || die "Can't run ipconfig: $!\n";
73 while (<IPNUM>)
75 if (/Address/)
77 $uid = (split (/: (\d+)\.(\d+)\.(\d+)\.(\d+)/))[4];
81 close IPNUM;
83 return $uid;
85 else
87 return getpwnam (getlogin ());
91 # Waits until a file exists
92 sub waitforfile
94 local($file) = @_;
95 sleep 1 while (!(-e $file && -s $file));
98 sub waitforfile_timed
100 my $file = shift;
101 my $maxtime = shift;
102 while ($maxtime-- != 0) {
103 if (-e $file && -s $file) {
104 return 0;
106 sleep 1;
108 return -1;
111 $sleeptime = 5;
113 CheckForExeDir ();
114 CheckForConfig ();