Who works intensively with (several) remote shells knows how much is important to have a good terminal emulator. I found Zoc : Wiki (Zoc) (site : Click Here)
There are several features but in my case what I need :
- automation : scriptable macro with “live recording” & “REXX script language”
- hosts directory with recorded login procedures
- several terminal emulations
- “Colorful tabs” each tab is opened with a different color gradient ( 🙂 so it is simple to recognize the correct shell where don’t execute “shutdown” command)
Below some notes.
#1 REXX : UUencode / UUdecode remote copy
UUencode is a utility that allows to convert from binary to “printable ASCII” string and vice versa.
UUencode gets a binary file and it prints to stdout an encoded printable string.
UUdecode is the other face of coin : it gets in stdin an encoded string and produce a binary file.
the package is shareutils (sharutils-4.2.1-22.2.i386.rpm)
Since they are generally available (on server) I use UUencode/UUdecode to copy remotely (little) files (using Terminal stdin/stdout as input/output with cut&paste) :
on local terminal$ cat localfile.bin | uuencode
Control-C on local Terminal in order to copy in clipboard encoded string
on remote terminal$ uudecode >file.bin
Control-V on remote terminal in order to paste on stdin
The below REXX script does this automatically asking to you which local file you want to upload.
CALL ZocCls
file= ZocGetFilename("Select file to upload")
IF file="##CANCEL##" THEN DO
CALL ZocCls
filename = FILESPEC('N', file)
rnd=RANDOM(10000)
tstart=TIME('T')
tmpfile="/tmp/tmp-"filename"-"rnd"-"tstart".uenc"
SAY "*********************************************************"
SAY "UPLOAD FILE :"file" ("filename")"
SAY "TEMP FILE : "tmpfile
SAY "*********************************************************"
ADDRESS SYSTEM "uuencode """file""" """filename"""" WITH OUTPUT STREAM tmpfile
totalLines=lines(tmpfile,'C')
count=0
CALL ZocSend "uudecode^M"
DO WHILE lines(tmpfile)>0
count=count+1
IF count//300==0 THEN DO
tnow=TIME('T')
telapsed=tnow-tstart
perc=count*100/totalLines
CALL ZocNotify "UPLOAD STATUS "count" OF "totalLines" ("perc"%) elapsed: "telapsed" sec"
END
line = linein(tmpfile)
CALL ZocSendRaw line
CALL ZocSend "^M"
END
tnow=TIME('T')
telapsed=tnow-tstart
perc=count*100/totalLines
SAY "UPLOAD STATUS "count" OF "totalLines" ("perc"%) elapsed: "telapsed" sec"
SAY "*********************************************************"
ADDRESS SYSTEM "rm """tmpfile""""
END
#2 Automation of SCP sequence on servers
When you are not connected directly (with a single ssh hop) to a server then could be useful to automate the sequence of scp commands:
[LocalComputer]->[1. SCP to GW]->[2. SCP to FirstServer]->[.3 SCP to TargetServer]
Below script allows to you to select (with a file widget) the file to copy and remote server.
/* select file to copy */ CALL ZocCls file= ZocGetFilename("Select file to upload") IF file="##CANCEL##" THEN DO /*Select target server*/ answer= ZocRequestList("Please select destination host", "1. Server A", "2 Server B") destination="" IF answer=0 THEN DO destination="server1.mynet.net" END IF answer=1 THEN DO destination="server2.mynet.net" END /*scp 1 from local to remote first jump*/ CALL ZocSend "scp "||file||" my.username@first.hop.server.net:^M" CALL ZocWait "password" CALL ZocSend "yourpassword^M" /*ssh 1 from local to remote first jump*/ CALL ZocSend "ssh my.username@first.hop.server.net^M" CALL ZocWait "password" CALL ZocSend "yourpassword^M" CALL ZocWait "first.hop.server.net:~%" /*depend by prompt of your server*/ filename = FILESPEC('N', file) /*scp 2 from first jump to second*/ CALL ZocSend "scp "||filename||" my.username@"destination":^M" CALL ZocWait "password" CALL ZocSend "yourpassword^M" /*ssh 3 from first jump to second*/ CALL ZocSend "ssh my.username@"destination"^M" CALL ZocWait "password" CALL ZocSend "yourpassword^M" CALL ZocWait "first.hop.server.net:~%" /*depend by prompt of your server*/ END
When this script has finished you have file copied on target server and your Terminal open to remote server.
As said this script allows to you to select a final server destination from a list :

#3 Autologin when you open a ZOC tab
( : see *update notes later at point #4 )
If you need to automate autologin when you open a ZOC tab (for example opening a local shell) :
Select from menu “[ZOC]-> Preference”
Fill ZOC-Events field with path :
$(ZOCFILES)/REXX/Advanced/ZOC Specials/zocevent.zrx

edit zocevent.zrx
/Users/<user>/Library/Application Support/ZOC6 Files/REXX/Advanced/ZOC Specials
– remove
EXIT /*>>>>>>> to make it all work delete this line <<<<<<<<<<<<< */
+ add the red line
/* if a ZOC device will be opened *********************************/
WHEN Event=”DEVOPEN” THEN DO
CALL ZocAutoConnect “localhost”
END /* WHEN */
#4 Autologin *UPDATE
Well “#3 Autologin when you open a ZOC tab” has effects if you use “Host Directory” : connection to remote host is ignored
A better way for auto login is :
remove from zocevent.zrx Event=”DEVOPEN” handler (see point #3)
select in preference menu (Z[ZOC->preference->Tabs) :
“Performs this Action…” -> Startup Script

4.1) create a “Startup Script” Startup.zrx file in : /Users/<user>/Library/Application Support
you can discovery the right position in “File” menu selecting “Show Data Folder”

4.2) Startup.zrx has to contains (only important line is in green bold)
SAY ” ___ _ “
SAY “( _` ( ) “
SAY “| (_) ) _ _ ___ _ _ ___ _ __ _ _ ___ | |/’) “
SAY “| _ <‘( ) ( )/’,__)( ) ( ) /’___)( ‘__)/’_` ) /’___)| , < “
SAY “| (_) )| (_) |__, | (_) |( (___ | | ( (_| |( (___ | |` “
SAY “(____/’`___/'(____/`__, |`____)(_) `__,_)`____)(_) (_)”
SAY ” ( )_| | “
SAY ” `___/’ “
CALL ZocConnect “127.0.0.1”

Add Comment