36
36
* PVM console commands.
39
* Revision 1.45 2004/01/14 18:46:20 pvmsrc
40
* Added new AIX5* arches.
43
* Revision 1.44 2001/09/26 23:37:22 pvmsrc
44
* Made hd_vmid additions to hostd mirror struct...
45
* - don't know if this is really necessary, but wtf.
48
* Revision 1.43 2001/09/25 21:18:13 pvmsrc
49
* Minor TMPNAMFUN()/tmpnam() cleanup.
50
* - moved macro def to pvm3.h, renamed PVMTNPMAN().
51
* - same for LEN_OF_TMP_NAM -> PVMTMPNAMLEN.
52
* - mostly a huge waste of time, since *both* tmpnam() & mktemp()
53
* produce the same "dangerous" warning message in Linux/gcc...
57
* Revision 1.42 2001/08/17 20:18:32 pvmsrc
58
* Added --host= option to spawn command.
59
* - allows passing IP address in place of host name.
60
* - used gnu-like syntax at Paul Gray's suggestion... :-)
63
* Revision 1.41 2001/07/30 17:46:08 pvmsrc
64
* O.K., Paul's bug was legit. Some goofy (Mandrake) Linux passes
65
* stderr back through rsh...
66
* - weed out lines with stuff like "/bin/ls: ... No such file..."
69
* Revision 1.40 2001/07/30 16:52:00 pvmsrc
70
* Minor cleanup to auto-diag routine...
71
* - slightly more solid checking for leftover /tmp/pvmd.* files.
72
* - inspired by a pseudo-bug report from Paul Gray, could be bogus...
76
* Revision 1.39 2001/07/30 16:02:31 pvmsrc
80
* Revision 1.38 2001/04/23 14:41:41 pvmsrc
81
* Tweaked spawn_cmd() parsing to allow -:wd working directory spec.
82
* - i.e. without a host or arch specified...
83
* - fixed help spawn text.
86
* Revision 1.37 2001/02/02 17:05:50 pvmsrc
87
* Fixed typo in Win32 diagnostic message output.
90
* Revision 1.36 2000/03/29 20:01:40 pvmsrc
94
* Revision 1.35 2000/02/18 22:01:42 pvmsrc
95
* Cleaned up Windows side of diagnose_cant_start_pvm()...
96
* - lose any '\r' at end of rsh output.
97
* - use "chdir" instead of "pwd" for Windows O.S. check.
101
* Revision 1.34 2000/02/15 18:06:20 pvmsrc
102
* Modified jobs_cmd() to dump task ids for traced jobs...
103
* - can't use output buffers, must use TRC_ID->tevtask_list list.
104
* - snagged necessary state constants from trclib.h, can't just
105
* #include it, as it #includes fricking everything... :-Q
108
* Revision 1.33 2000/02/15 17:06:42 pvmsrc
109
* Added new getopt / setopt console commands.
110
* - for setting PVM console task's PVM options (like PvmShowTids).
111
* Fixed debug flags in tickle help.
114
* Revision 1.32 2000/02/14 20:30:59 pvmsrc
115
* Lose #define-d RSHCOMMAND usage.
116
* - use new pvmgetrsh() routine, which checks for PVM_RSH or else
117
* uses old RSHCOMMAND interface.
120
* Revision 1.31 2000/02/10 22:17:38 pvmsrc
121
* Cleaned up diagnose_cant_start_pvmd() test routine a bunch.
122
* - replaced gobs of inline code with new do_rsh_cmd() routine.
123
* - added new check_env_var() routine to sort through extra
124
* garbage in rsh commands when checking env vars...
127
* Revision 1.30 2000/02/10 20:43:37 pvmsrc
128
* Added checking for new PVM_TMP env var on remote host.
129
* - in diagnose_cant_start_pvm()...
130
* - use in place of hard-coded /tmp or \TEMP...
133
* Revision 1.29 2000/01/26 23:34:17 pvmsrc
134
* *** Added Killer Routine of All Time - diagnose_cant_start_pvm() ***
135
* Nearly 800 lines of pure joy! :-D
136
* - on "Can't start pvmd" error, tries to rsh to host and checks
137
* everything from rhosts to $PVM_ROOT to /tmp/pmvd.* crap files.
138
* - should theoretically work on both Unix and Windows machines,
139
* for both Unix and Windows remote hosts (tested for Unix :-).
140
* - with any luck this will cut bug mail in half... yeah right.
39
143
* Revision 1.28 1999/07/08 18:59:39 kohl
40
144
* Fixed "Log" keyword placement.
41
145
* - indent with " * " for new CVS.
663
diagnose_cant_start_pvm( hostline )
690
/* Extract Raw Host Name from Add Command */
692
if ( parsehost(hostline, &hp) < 0 ) {
693
printf( "Error Parsing Host String!\n" );
694
printf( "Cannot Auto-Diagnose!\n" );
698
/* Get Local Hostname */
700
gethostname( lhost, 1024 );
705
if ( (pw = getpwuid( getuid() )) != NULL )
706
strcpy( user, pw->pw_name );
708
strcpy( user, "<your_user_name>" );
710
strcpy( user, MyGetUserName() );
713
/* Ping / Timeout Test */
716
* Maybe later - for now rsh returns "Connection timed out"
718
printf( "Pinging Host \"%s\"...\n", hp.hd_name );
720
sprintf( tcmd, "ping -c 1 %s 1>%s 2>&1", hp.hd_name, tfile );
724
fp = fopen( tfile, "r" );
727
while ( fgets( result, 1024, fp ) != NULL ) {
728
printf( "%s\n", result );
733
printf( "Ping Command Failed - Test Skipped...\n" );
738
/* Verify Rsh Path */
740
printf( "Verifying Local Path to \"rsh\"...\n" );
742
strcpy( tcmd, pvmgetrsh() );
744
if ( stat( tcmd, &statck ) < 0 ) {
745
printf( "\nError - File %s Not Found!\n", tcmd );
747
printf( "Use \"whereis rsh\" or \"which rsh\" to determine\n" );
748
printf( "where \"rsh\" is on your system and modify the\n" );
749
printf( "$PVM_ROOT/conf/$PVM_ARCH.def configuration file\n" );
751
printf( "Determine the path to the \"rsh\" command on your\n" );
752
printf( "system, and edit %PVM_ROOT%\\conf\\WIN32.def\n" );
754
printf( "to adjust the path for the -DRSHCOMMAND=\\\"\\\"\n" );
755
printf( "flag. Then recompile PVM and your applications.\n" );
760
printf( "Rsh found in %s - O.K.\n", tcmd );
764
if ( do_rsh_cmd( &hp, "Testing Rsh/Rhosts Access to",
765
"echo YES", result, 1024 ) ) {
768
if ( !strncmp( result, "YES", 3 ) )
769
printf( "Rsh/Rhosts Access is O.K.\n" );
771
printf( "\nRsh/Rhosts Access FAILED - \"%s\"\n", result );
772
printf( "Make sure host %s is up and connected to\n",
774
printf( "a network and check its DNS / IP address.\n" );
775
printf( "Also verify that %s is allowed\n", lhost );
776
printf( "rsh access on %s\n", hp.hd_name );
777
printf( "Add this line to the $HOME/.rhosts on %s:\n",
779
printf( "%s %s\n", lhost, user );
787
/* Is Remote Host O.S. Windows or Unix? */
789
if ( do_rsh_cmd( &hp, "Checking O.S. Type (Unix test) on",
790
"pwd", result, 1024 ) ) {
793
if ( result[0] == '/' ) {
794
printf( "Host %s is Unix-based.\n", hp.hd_name );
797
else if ( do_rsh_cmd( &hp, "Checking O.S. Type (Win test) on",
798
"chdir", result2, 1024 ) ) {
801
len = strlen( result2 );
802
if ( len >= 3 && result2[0] >= 'A' && result2[0] <= 'Z'
803
&& result2[1] == ':' && result2[2] == '\\' ) {
804
printf( "Host %s is Windows-based.\n", hp.hd_name );
807
/* Hmmm... Go Figure. */
809
len = strlen( result );
810
for ( i=0 ; i < len - 1 && remote_os < 0 ; i++ ) {
811
if ( result[i] == '/' ) {
812
printf( "Assuming Host %s to be Unix-based.\n",
816
else if ( result[0] == '\\' ) {
818
"Assuming Host %s to be Windows-based.\n",
823
if ( remote_os < 0 ) {
824
len = strlen( result2 );
826
printf( "Assuming Host %s to be Unix-based.\n",
831
for ( i=0 ; i < len - 1 && remote_os < 0 ;
833
if ( result2[i] == '/' ) {
835
"Assuming Host %s to be Unix-based.\n",
839
else if ( result2[0] == '\\' ) {
841
"Assuming Host %s to be Windows-based.\n",
848
if ( remote_os < 0 ) {
849
printf( "Error - Cannot Determine Remote O.S.!\n" );
850
printf( "Can't Auto-Diagnose.\n" );
861
if ( do_rsh_cmd( &hp,
863
"Checking $PVM_ROOT on" : "Checking %PVM_ROOT% on",
865
"echo $PVM_ROOT" : "echo %PVM_ROOT%",
868
/* check for undefined variable (Unix) */
869
if ( remote_os == 0 && !check_env_var( "PVM_ROOT", result ) ) {
871
"\nThe $PVM_ROOT Environment Variable is Not Set!\n" );
872
printf( "Use one of the shell *.stub files in\n" );
873
printf( "the pvm3/lib directory to set up the\n" );
874
printf( "PVM environment on host %s.\n", hp.hd_name );
878
/* check for undefined variable (Windows) */
879
else if ( remote_os == 1 && !strncmp( result, "ECHO", 4 ) ) {
881
"\nThe %%PVM_ROOT%% Environment Variable is Not Set!\n" );
882
printf( "Check your PVM installation on host %s or\n",
884
printf( "set the %%PVM_ROOT%% environment variable\n" );
885
printf( "in the C:\\AUTOEXEC.BAT file to point to\n" );
886
printf( "PVM3.4 directory:\n" );
887
printf( "set PVM_ROOT = C:\\PVM3.4\n" );
891
/* check for bogus relative path (Unix) */
892
else if ( remote_os == 0 && result[0] != '/' ) {
893
printf( "\nThe value of the $PVM_ROOT environment\n" );
894
printf( "variable on %s is invalid (\"%s\").\n",
895
hp.hd_name, result );
896
printf( "Use the absolute path to the pvm3/ directory.\n" );
900
/* check for bogus relative path (Windows) */
901
else if ( remote_os == 1 && ( result[1] != ':'
902
|| result[2] != '\\' ) ) {
903
printf( "\nThe value of the %%PVM_ROOT%% environment\n" );
904
printf( "variable on %s is invalid (\"%s\").\n",
905
hp.hd_name, result );
907
"Use the absolute path to the PVM3.4 directory.\n" );
911
/* appears to be O.K., fall through to next test */
913
strcpy( pvmroot, result );
914
printf( "%sPVM_ROOT%s on %s Appears O.K. (\"%s\")\n",
915
( remote_os == 0 ) ? "$" : "%",
916
( remote_os == 0 ) ? "" : "%",
917
hp.hd_name, pvmroot );
923
/* Pvmd Script Existence Test (a.k.a. $PVM_ROOT Validity Test) */
925
if ( do_rsh_cmd( &hp, "Verifying Location of PVM Daemon Script on",
926
( remote_os == 0 ) ? "\\ls $PVM_ROOT/lib/pvmd"
927
: "dir /B /L %PVM_ROOT%\\lib\\pvmd.bat",
930
/* expected pvmd script path */
931
if ( remote_os == 0 )
932
sprintf( tmp, "%s/lib/pvmd", pvmroot );
934
sprintf( tmp, "pvmd.bat" );
935
/* check existence of pvmd script */
936
if ( strcmp( result, tmp ) ) {
937
printf( "\nPVM Daemon Script \"%s\"\n", tmp );
938
printf( "Was Not Found on %s\n", hp.hd_name );
939
printf( "Please check the setting of %sPVM_ROOT%s...\n",
940
( remote_os == 0 ) ? "$" : "%",
941
( remote_os == 0 ) ? "" : "%" );
946
printf( "PVM Daemon Script Found (\"%s\")\n", tmp );
951
/* Determine Remote Host Architecture */
953
if ( do_rsh_cmd( &hp, "Determining PVM Architecture on",
954
( remote_os == 0 ) ? "echo $PVM_ARCH" : "echo %PVM_ARCH%",
957
/* check for undefined variable */
958
if ( ( remote_os == 0 && check_env_var( "PVM_ARCH", result ) )
960
&& strncmp( result, "ECHO", 4 ) ) ) {
961
printf( "%sPVM_ARCH%s on %s set to %s\n",
962
( remote_os == 0 ) ? "$" : "%",
963
( remote_os == 0 ) ? "" : "%",
964
hp.hd_name, result );
965
strcpy( pvmarch, result );
968
printf( "%sPVM_ARCH%s not set on %s\n",
969
( remote_os == 0 ) ? "$" : "%",
970
( remote_os == 0 ) ? "" : "%",
972
if ( remote_os == 1 ) {
973
printf( "Assuming WIN32.\n" );
974
strcpy( pvmarch, "WIN32" );
983
/* Manually Determine Remote Host Architecture (Unix Only) */
985
if ( remote_os == 0 && pvmarch[0] == '\0' ) {
987
if ( do_rsh_cmd( &hp,
988
"Manually Determining PVM Architecture on",
989
"$PVM_ROOT/lib/pvmgetarch", result, 1024 ) ) {
991
len = strlen( result );
994
printf( "$PVM_ARCH for %s is %s.\n",
995
hp.hd_name, result );
996
strcpy( pvmarch, result );
999
printf( "Could Not Determine $PVM_ARCH.\n" );
1000
printf( "Can't Further Auto-Diagnose.\n" );
1009
/* Existence of pvmd3 Executable? */
1011
if ( remote_os == 0 )
1012
sprintf( tmp, "\\ls $PVM_ROOT/lib/%s/pvmd3", pvmarch );
1014
sprintf( tmp, "dir /B /L %%PVM_ROOT%%\\lib\\%s\\pvmd3.exe",
1017
if ( do_rsh_cmd( &hp,
1018
"Verifying Existence of PVM Daemon Executable on",
1019
tmp, result, 1024 ) ) {
1021
/* expected pvmd executable path */
1022
if ( remote_os == 0 )
1023
sprintf( tmp, "%s/lib/%s/pvmd3", pvmroot, pvmarch );
1025
sprintf( tmp, "pvmd3.exe" );
1026
/* check existence of pvmd executable */
1027
if ( strcmp( result, tmp ) ) {
1028
printf( "\nPVM Daemon Executable \"%s\"\n", tmp );
1029
printf( "Was Not Found on %s!\n", hp.hd_name );
1030
printf( "Has PVM been compiled there?\n" );
1035
printf( "PVM Daemon Executable Found (\"%s\")\n", tmp );
1040
/* Determine Remote Host Temp Directory (if set) */
1042
if ( do_rsh_cmd( &hp, "Determining PVM Temporary Directory on",
1043
( remote_os == 0 ) ? "echo $PVM_TMP" : "echo %PVM_TMP%",
1046
/* check for undefined variable */
1047
if ( ( remote_os == 0 && check_env_var( "PVM_TMP", result ) )
1049
&& strncmp( result, "ECHO", 4 ) ) ) {
1050
printf( "%sPVM_TMP%s on %s set to %s\n",
1051
( remote_os == 0 ) ? "$" : "%",
1052
( remote_os == 0 ) ? "" : "%",
1053
hp.hd_name, result );
1054
strcpy( pvmtmp, result );
1057
printf( "%sPVM_TMP%s not set on %s\n",
1058
( remote_os == 0 ) ? "$" : "%",
1059
( remote_os == 0 ) ? "" : "%",
1061
if ( remote_os == 1 ) {
1062
printf( "Assuming C:\\TEMP.\n" );
1063
strcpy( pvmtmp, "C:\\TEMP" );
1066
printf( "Assuming /tmp.\n" );
1067
strcpy( pvmtmp, "/tmp" );
1074
/* Pvmd Already Running There / Leftover Pvmd Files? */
1076
if ( remote_os == 0 )
1077
sprintf( tmp, "\\ls -l %s/pvmd.* | grep %s",
1078
pvmtmp, ( hp.hd_login != NULL ) ? hp.hd_login : user );
1080
/* should really also check %TEMP% */
1081
sprintf( tmp, "dir /B /L %s\\pvmd.%s",
1082
pvmtmp, ( hp.hd_login != NULL ) ? hp.hd_login : user );
1084
if ( do_rsh_cmd( &hp, "Checking for Leftover PVM Daemon Files on",
1085
tmp, result, 1024 ) ) {
1087
len = strlen( result );
1088
/* Find Any? (Unix) */
1089
if ( remote_os == 0 ) {
1090
/* search for a '/pvmd', if found assume a hit */
1091
for ( i=0 ; i < len - 1 ; i++ ) {
1092
/* bail out if "/bin/ls: ... No such file..." */
1093
if ( !strncmp( result + i, "ls:", 3 ) )
1095
else if ( !strncmp( result + i, "/pvmd.", 6 ) ) {
1096
printf( "\nPVM Daemon Files Found on %s!\n",
1099
"PVM Could Already Be Running or else it\n" );
1100
printf( "crashed and left behind a %s/pvmd.<uid>\n",
1102
printf( "daemon file.\n" );
1104
"Halt PVM if it is running on %s, or else\n",
1106
printf( "remove any leftover %s/pvmd.* files.\n",
1112
printf( "No PVM Daemon Files Found.\n" );
1114
/* Find Any? (Windows) */
1115
else if ( remote_os == 1 && !strncmp( result, "pvmd", 4 ) ) {
1116
printf( "\nPVM Daemon Files Found on %s!\n", hp.hd_name );
1117
printf( "Either PVM is Already Running or else it\n" );
1118
printf( "crashed and left behind a \\TEMP\\pvmd.%s\n",
1119
( hp.hd_login != NULL ) ? hp.hd_login : user );
1120
printf( "daemon file.\n" );
1121
printf( "Halt PVM if it is running on %s, or else\n",
1123
printf( "remove any leftover \\TEMP\\pvmd.* files.\n" );
1127
/* No Pvmd Files, O.K.? */
1129
printf( "No PVM Daemon Files Found.\n" );
1134
/* Hmmm... Must Be O.K. (ha ha ha) */
1136
printf( "\nHost %s Appears to Be Correctly Configured.\n",
1139
printf( "Please check your local %s/pvml.%d log file\n",
1140
pvmgettmp(), getuid() );
1142
printf( "Please check your local %s\\pvml.%s log file\n",
1143
pvmgettmp(), user );
1145
printf( "for error messages, or else email \"%s\" for\n",
1146
"pvm@msr.csm.ornl.gov" );
1147
printf( "further assistance.\n" );
1153
do_rsh_cmd( hp, label, cmd, result, rsize )
1169
/* Generate Temporary File for Test Output */
1171
(void)PVMTMPNAMFUN(tfile);
1173
/* Dump Test Label */
1175
printf( "%s Host \"%s\"...\n", label, hp->hd_name );
1177
/* Construct Rsh Command */
1179
sprintf( tcmd, "%s ", pvmgetrsh() );
1181
if ( hp->hd_login != NULL ) {
1182
sprintf( tmp, "-l %s ", hp->hd_login );
1183
strcat( tcmd, tmp );
1186
sprintf( tmp, "%s '%s' ", hp->hd_name, cmd );
1187
strcat( tcmd, tmp );
1190
sprintf( tmp, "1>%s 2>&1", tfile );
1192
sprintf( tmp, "> %s", tfile );
1194
strcat( tcmd, tmp );
1196
/* Execute Rsh Command */
1200
/* Collect Rsh Command Results */
1202
fp = fopen( tfile, "r" );
1205
if ( fgets( result, rsize, fp ) != NULL ) {
1206
/* strip off '\n' */
1207
len = strlen( result );
1208
if ( len > 0 && result[ len - 1 ] == '\n' )
1209
result[ len - 1 ] = '\0';
1210
/* strip off any '\r' */
1211
len = strlen( result );
1212
if ( len > 0 && result[ len - 1 ] == '\r' )
1213
result[ len - 1 ] = '\0';
1216
printf( "Error Parsing Output - Can't Auto-Diagnose.\n" );
1222
printf( "Rsh Command Failed - Check Your Execution Path!\n" );
1232
check_env_var( name, result )
1238
int nlen = strlen( name );
1240
/* Standard "FOO - Undefined variable" Response? */
1242
if ( !strncmp( result, name, nlen ) )
1245
/* Check for preceding garbage before standard response */
1249
while ( *ptr != '\0' && strlen( ptr ) >= nlen )
1251
if ( !strncmp( ptr, name, nlen ) )
1257
/* Look for "[Uu]ndefined" in result... */
1261
while ( *ptr != '\0' && strlen( ptr ) >= 9 )
1263
if ( !strncmp( ptr, "Undefined", nlen )
1264
|| !strncmp( ptr, "undefined", nlen ) )
1278
* Parse hostfile line into hostd.
1279
* (lifted from pvm3/src/host.c - pvmd code... hacked a little :-)
1287
char *av[10]; /* parsed words */
1291
ac = sizeof(av)/sizeof(av[0]);
1292
if (acav(buf, &ac, av)) {
1293
printf("parsehost(): line too long\n");
1299
/* Initialize Host Struct Fields */
1301
hp->hd_name = (char *) NULL;
1302
hp->hd_arch = (char *) NULL;
1303
hp->hd_login = (char *) NULL;
1304
hp->hd_dpath = (char *) NULL;
1305
hp->hd_epath = (char *) NULL;
1306
hp->hd_bpath = (char *) NULL;
1307
hp->hd_wdir = (char *) NULL;
1308
hp->hd_sopts = (char *) NULL;
1309
hp->hd_vmid = (char *) NULL;
1311
/* add options to host descriptor */
1314
if (!strncmp(av[ac], "lo=", 3)) {
1316
MY_FREE(hp->hd_login);
1317
hp->hd_login = STRALLOC(av[ac] + 3);
1320
if (!strncmp(av[ac], "dx=", 3)) {
1322
MY_FREE(hp->hd_dpath);
1323
hp->hd_dpath = STRALLOC(av[ac] + 3);
1326
if (!strncmp(av[ac], "ep=", 3)) {
1328
MY_FREE(hp->hd_epath);
1329
hp->hd_epath = STRALLOC(av[ac] + 3);
1332
if (!strncmp(av[ac], "sp=", 3)) {
1333
hp->hd_speed = atoi(av[ac] + 3);
1334
/* hp->hd_flag |= HF_SPEED; */
1337
if (!strncmp(av[ac], "bx=", 3)) {
1339
MY_FREE(hp->hd_bpath);
1340
hp->hd_bpath = STRALLOC(av[ac] + 3);
1343
if (!strncmp(av[ac], "wd=", 3)) {
1345
MY_FREE(hp->hd_wdir);
1346
hp->hd_wdir = STRALLOC(av[ac] + 3);
1349
if (!strncmp(av[ac], "so=", 3)) {
1351
MY_FREE(hp->hd_sopts);
1352
hp->hd_sopts = STRALLOC(av[ac] + 3);
1355
if (!strncmp(av[ac], "ip=", 3)) {
1357
MY_FREE(hp->hd_aname);
1358
hp->hd_aname = STRALLOC(av[ac] + 3);
1361
if (!strncmp(av[ac], "id=", 3)) {
1363
MY_FREE(hp->hd_vmid);
1364
hp->hd_vmid = STRALLOC(av[ac] + 3);
1367
printf("parsehost(): unknown option \"%s\"\n", av[ac]);
1374
MY_FREE(hp->hd_name);
1375
hp->hd_name = STRALLOC(av[0]);
500
1383
alias_cmd(ac, av)