REM Copy a file to a remote host REM Usage: scp [host] [...] REM Will login (porthack if needed) to each host and copy the file to the destination REM File is stored in memory, and written to last host. Avoids ftp delays unless exe NEEDFTP=0 IF ARGC% < 2 THEN PRINT "Usage: scp [host] [...]" : END FILENAME$=ARGV$(1) IF INSTR(FILENAME$, "exe", 0) > 0 THEN NEEDFTP=1 IF NEEDFTP=1 THEN GOSUB 6000 IF NEEDFTP = 0 GOSUB 4000 : REM Read File 1 LASTHOST$ = TH_SED$(TH_HOSTNAME$,"\s.*","") 10 FOR I = 2 TO ARGC%-1 LASTHOST$ = TH_SED$(TH_HOSTNAME$,"\s.*","") IF TH_HASLOGIN(ARGV$(I)) = 0 THEN GOSUB 1000 PRINT "Trying " + ARGV$(I) + " ("+STR$(I-1)+"/"+STR$(ARGC%-2)+")..." 21 TH_EXEC "rlogin "+ARGV$(I), DUMP$ IF NEEDFTP = 1 THEN GOSUB 2000 30 NEXT I IF NEEDFTP = 0 THEN GOSUB 5000 END 1000 PRINT "No login on " + ARGV$(I) IF INSTR(DIR$, "porthack", 0) = -1 THEN GOSUB 2000 TH_EXEC("porthack " + ARGV$(I)) RETURN 2000 IF INSTR(DIR$, FILENAME$, 0) = -1 THEN GOSUB 2500 PRINT "File already on " + TH_HOSTNAME$ RETURN 2500 PRINT FILENAME$+" not on " + TH_HOSTNAME$ + ". Trying to fetch it from " + LASTHOST$ TH_EXEC "ftp " + LASTHOST$, DUMP$ TH_EXEC "get " + FILENAME$ TH_EXEC "quit", DUMP$ RETURN 4000 REM Read File CONTENT$="" OPEN(FILENAME$), AS #1 4010 IF EOF(1) THEN GOTO 4020 INPUT# 1, L$ CONTENT$=CONTENT$+L$+CHR$(13)+CHR$(10) GOTO 4010 4020 CLOSE #1 RETURN 5000 REM Sub Write File PRINT "Writing file " + FILENAME$ OPEN(FILENAME$), AS #1 PRINT# 1, CONTENT$ CLOSE #1 RETURN 6000 PRINT "EXE File- Requires FTP." PRINT "Options:" PRINT " r) rlogin to each host" PRINT " d) dial remote host (no auto ftp)" PRINT " q) quit" 6001 PRINT "Continue? (r/d/q)" CONT$ = INKEY$ IF CONT$ = "r" OR CONT$ = "R" THEN RETURN IF CONT$ = "q" OR CONT$ = "Q" THEN PRINT "Canceling Transfer" : END IF CONT$ = "d" OR CONT$ = "D" THEN GOTO 8000 GOTO 6001 8000 PRINT "Dialing remote host" HOST$=ARGV$(ARGC%-1) TH_EXEC "uumap " + HOST$ + " | grep '#T'", RPHONE$ PHONE$ = TH_SED$(RPHONE$, ".*#T\s+(\d+).*", "\1") PRINT "Dialing " + PHONE$ TH_EXEC "dial " + PHONE$ END