comgt(1)
β¨ comgt β the manual, bestie edition β¨
okay so you wanna talk to your datacard. comgt is the tool. it's the Option GlobeTrotter GPRS/EDGE/3G/HSDPA and Vodafone 3G/GPRS datacard control tool, and honestly? she's that girl. this is comgt(1) in the flesh. let's get into it π«Ά
πΈ SYNOPSIS πΈ
comgt -d device -ehstvVx script
π OPTIONS π
-d deviceβ sets which device talks to the datacard. skip it andcomgtgoes hunting in this order:/dev/noz2, then/dev/ttyUSB2, then/dev/modem.-eβ turns on serial communications echo. she's gonna repeat after herself π¬-hβ shows you the summary help and then dips. that's it, that's the whole job.-sβ don't run the internal default script before an external script. like, skip the opening act, straight to the main character β¨-tβ swaps in an alternate line terminator (default"0).-vβ verbose mode, babes. it traces scripts as they run, which is literally made for debugging scripts. every little thing, on the record π-Vβ prints the Version information. iconique.-xβ for internal and external scripts, every reference to115200baud gets converted to57600. this is for data cards that are picky and just don't vibe with115200baud β think the GlobeTrotter EDGE. she's sensitive π₯Ί
π¦ DESCRIPTION π¦
comgt is a scripting language interpreter. its whole thing is establishing communications on serial lines and through PCMCIA modems, plus GPRS and 3G datacards. no cap.
and she comes with some features you genuinely do not see in other utilities of the same type. rare. collectible. π
β Features β
- Pre-defined built-in scripts for 2G/3G datacard control
- Simple, BASIC-like script language.
- Command-line and file sourcing of script.
- Multi-response waitfor.
- waitquiet permits line stabilization.
- In-line text capture.
- Multi-process support: fork, wait, kill, exit.
- Debugging verbose and log output.
- logging to file.
- Flow control: goto, gosub, return, if, else.
- Low-impact on system resources.
- Time commands and functions.
- String manipulations.
- Environment manipulation: env(), putenv.
- External utilities system calls: system, exec.
π Supported GPRS and 3G datacards π
comgt has been tested against GlobeTrotter GPRS, EDGE, Combo EDGE, 3G, 3G EDGE, HSDPA and GlobeTrotter Fusion, and also Vodafone 3G. she can set the PIN and show you all kinds of info about datacards before a PPP connection gets started. and because the GlobeTrotter and Vodafone 3G/GPRS datacards have a secondary serial interface, you can actually monitor them while a PPP connection is live and moving data. multitasking queen π
comgt is primarily designed to work with the GlobeTrotter range of datacards, but she should be compatible with any other GPRS or 3G datacard β as long as its interface is implemented as one or more serial or USB serial devices, and it's controlled and queried by an implementation of the Hayes command interface with the same AT command extensions used by the listed datacards. iykyk.
π Using comgt π
comgt has exactly one function: run a script. that's the whole personality. it might be one of a number of "standard" internal scripts, or it might be an external script, and both types get invoked the same way. the "standard" scripts are built right into comgt and they work for serially connected modems, built-in modems, PCMCIA modems, and also the GlobeTrotter GPRS and the Vodafone 3G/GPRS datacards.
there's a search priority order for scripts β write this down bestie:
- internal
- working directory
/etc/comgt
β¨ Built-in scripts β¨
comgt
this runs the default internal script. running comgt with no script specified, like comgt -d /dev/ttyS1, makes it check for a PIN and prompt you if one's required. next up it waits for the device to register, and then it reports the signal strength. if you don't specify a port with the -d option then /dev/modem is assumed. and if the -s switch isn't used, this default script runs before any external script. opening act, every time.
comgt help
lists these and the other options available. a little menu of possibilities π
comgt info
lists the datacard configuration.
comgt sig
prints the signal strength. πΆ
comgt reg
prints the registration state.
comgt 3G
puts a GlobeTrotter 3G/Fusion and Vodafone 3G into 3G network only mode (UMTS/HSDPA). 3G or nothing, periodt.
comgt 2G
puts a GlobeTrotter 3G/Fusion and Vodafone 3G into 2G network only mode (GSM/GPRS/EDGE).
comgt 3G2G
puts a GlobeTrotter 3G/Fusion and Vodafone 3G into 3G preferred mode (UMTS/HSDPA and GSM/GPRS/EDGE).
comgt GTEDGE
use this command to initialise GlobeTrotter EDGE and GlobeTrotter Combo EDGE cards before doing anything else. (it switches on the radio). do not skip this step, bestie, the radio is off π
comgt USA
switch to 900/1900 MHz band for USA operation. GlobeTrotter GPRS datacards only.
comgt EUROPE
switch to 900/1800 MHz band for European operation. GlobeTrotter GPRS datacards only.
comgt PIN
test the SIM PIN status, and use the environment variable COMGTPIN as the value.
comgt APN
set the APN of the datacard to the value contained in the COMGTAPN environment variable.
π§ Custom Scripts π§
as well as the built-in scripts, you can absolutely make your own. the following script sets a Vodafone 3G datacard or Option Fusion card's UMTS mode to GPRS:
#Set GPRS only mode
set com 115200n81
set senddelay 0.05
waitquiet 1 0.2
send "AT_OPSYS=0^m"
print "Setting GPRS only mode"
if you saved the above script as GPRS you would call it like this:
comgt GPRS
and if you needed to specify the port as well, then do this:
comgt -d /dev/ttyS1 GPRS
you can also pass environment parameters to a comgt script via $env().
π Replacing chat π
chat is a utility that comes with the ppp package (for Linux, anyway). with a set of expect-send string couples, it does enough to connect most people to ISPs and such. chat's use is very simple β but she isn't very flexible. and that's where comgt takes over.
comgt can be used in place of chat using the same strategy. for example, a pppd line reading:
pppd connect \
Β΄chat -v "" ATDT5551212 CONNECT "" ogin: ppp \
word: whitewaterΒ΄ \
/dev/cua1 38400 debug crtscts modem defaultroute
would, using comgt, read:
pppd connect Β΄comgt -s /root/scripts/isp.scrΒ΄ /dev/cua1 38400 \
debug crtscts modem defaultroute
and the isp.scr script would read:
send "ATDT5551212^m"
waitfor 60 "ogin:"
send "ppp^m"
waitfor 60 "word:"
send "whitewater^m"
of course it then becomes trivial to make this script a whole lot more functional by adding code for busy detect, re-dialing, etc... go off, upgrade her π
π₯ Verbose output π₯
when the verbose option is turned on, comgt reports everthing on the standard error channel. if it's turned on from the command line (-v), the output contains 4 sections.
- Command line argument actions these are actions taken because they were specified from the command line, like opening a communication device (
-d), etc... for these to be output, you must specify-vas the first argument. - List of arguments the number and list of arguments passed. this is useful in case you have a bunch of environment variables or quotes, back-quotes, backslashes on the command line and you're not sure what the script really sees.
- Script list a list of the script to execute. this may be a concatenation of the default internal script β unless this is suppressed by the
-soption β and a script file. every line is listed with its line number and character position. - Execution output list of commands as they are executed. the parser prints the line it's currently on, starting from the exact point where it's at to the end of the line. multiple command groups on a single line produce multiple output lines. verbose output may be mixed with script output (
print,eprintorlprint.)
here's an example:
$ comgt -v -d/dev/cua1 -s blah.scr
comgt 00:18:46 -> Verbose output enabled
comgt 00:18:46 -> Script file: blah.scr
comgt 00:18:46 -> argc:5
comgt 00:18:46 -> argv[0]=comgt
comgt 00:18:46 -> argv[1]=-v
comgt 00:18:46 -> argv[2]=-d/dev/cua1
comgt 00:18:46 -> argv[3]=-s
comgt 00:18:46 -> argv[4]=blah.scr
comgt 00:18:46 -> ---Script---
1@0000 set com 38400n81 let a=2
2@0025 print "9x",a,"=",9*a,"\n"
3@0051 sleep 5
4@0059 exit 0
comgt 00:18:46 -> ---End of script---
comgt 00:18:46 -> @0000 set com 38400n81 let a=2
comgt 00:18:46 -> @0017 let a=2
comgt 00:18:46 -> @0025 print "9x",a,"=",9*a,"\n"
9x2=18
comgt 00:18:46 -> @0051 sleep 5
comgt 00:18:51 -> @0059 exit 0
π Programming manual π
π Syntax π
the syntax used for comgt scripts is rather simple, somewhat BASIC-like. a script is a non-tokenized, pure ASCII text file containing lines terminated by newline characters (Unix standard.) scripts can be created and/or modified using any standard text editor (vi, vim, joe, pico, emacs, ed, microEmacs). lines in a comgt script read like so:
- Empty line
[indent]rem remark[indent][[:|label] LABEL] [command [arguments]] rem remark[indent][[:|label] LABEL] [command [arguments]] [command [arguments]]...
characters used for indentation are the space and tabulation characters. the rem command makes the script parser skip the rest of the line. the rem command can also be written as "#" or "//".
labels consist of lowercase and uppercase letters and digits. case is ignored in labels.
commands and their arguments are separated by spaces and/or tabs. command groups are separated by spaces, tabs, or newlines.
expressions must not contain spaces or tabs. this is ok:let n=x+76. this is not:let n= x + 76β because this space^would terminate theletcommand group. so keep your expressions tight, bestie, no gaps π«
π Error reporting π
when comgt detects a script error, it immediately turns on verbose mode, generates a dump (see the dump command), reports the error in three lines and stops the execution. the first line reported is the command group being executed, the second one shows where the parser got, and the third line reports the character position of the program counter, the error and the exit code. three lines of pure drama.
here's an example:
$ comgt -vs blar2.scr
where the blar2.scr script is:
inc n
dec d3
let a=58/3
let $d="fod"
let c=1/0
let $y4="sdfgsdfgsdfg"
the trace and error report looks like this:
comgt 11:20:15 -> Verbose output enabled
comgt 11:20:15 -> Script file: blar2.scr
comgt 11:20:15 -> argc:3
comgt 11:20:15 -> argv[0]=comgt
comgt 11:20:15 -> argv[1]=-vs
comgt 11:20:15 -> argv[2]=blar2.scr
comgt 11:20:15 -> ---Script---
1@0000 inc n
2@0007 dec d3
3@0015 let a=58/3
4@0027 let $d="fod"
5@0041 let c=1/0
6@0052 let $y4="sdfgsdfgsdfg"
comgt 11:20:15 -> ---End of script---
comgt 11:20:15 -> @0000 inc n
comgt 11:20:15 -> @0007 dec d3
comgt 11:20:15 -> @0015 let a=58/3
comgt 11:20:15 -> @0027 let $d="fod"
comgt 11:20:15 -> @0041 let c=1/0
comgt 11:20:15 -> -- Error Report --
comgt 11:20:15 -> ----> ^
comgt 11:20:15 -> Error @49, line 5, Division by zero. (6)
π Exit codes π
okay bestie so when comgt peaces out, it leaves behind an "exit code". it's literally just a number it hands back to whoever called it, so the caller knows if things went slay or went π. in everyday Unix, 0 (zero) means success and literally everything else means "whatever the author of the program decided it should mean." if you're in a shell script, or just rawdogging it on the command line, you can peek at what's inside $? right after you run comgt to see what its exit code was. iconic, right?
Example:
#!/bin/sh
comgt /root/bin/call-isp
if [ $? != 0 ]; then
echo "Oops! Something went wrong."
fi
the internal comgt error codes are, in order:
0: no problems whatsoever. apparently. β¨1: communication device problems.2: console (tty) device problems.3: memory problems.4: file or pipe problems.5: syntax errors.6: division by zero.7: variable mis-management.8: system problems. (couldnΒ΄t call/bin/shor some such)
π Commands π
: β alias: label
- Description β notes an anchor point for
gotoorgosubto branch to. it's giving bookmark energy π - Syntax β keyword must not contain any special characters.
- Note β must be first statement in a line.
- See Also β
goto,gosub,return.
Example:
:loop
gosub bravo
print "The time is ",$time(),"\n"
sleep 1
goto loop
label bravo
print "Twonk!\n"
return
abort
- Description β causes
comgtto callabort()and produce a core dump. - Syntax β
abort - See Also β
dump,exit.
bestie this one is the nuclear option, fr fr π
cd
- Description β change directory.
- Syntax β
cd directory - Notes β
-1is returned in%if the change could not be made. - Notes β
directoryis a string and thus could be a variable. - See Also β
$cwd().
Example:
cd "duh"
if % != 0 print "Could not cd into duh.\n"
close
- Description β closes file previously opened with
open. - Syntax β
close file - See Also β
open.
dec
- Description β decrements the content of an integer variable by 1.
- Syntax β
dec x - Notes β
xis fromatozora0toz9. - Notes β note that
"let x=x-1"also works. - See Also β
let,inc.
dump
- Description β lists all non-zero integer variables and modified string variables as log entries (standard error channel.)
- Syntax β
dump - See Also β
abort,exit
else
- Description β alternatively execute commands if last
"if"tested false. - Syntax β
else commands... - See Also β
if
Example:
if w<350 print "Wow! Imagine that.\n"
else print "Rush Limbaugh is a big fat bastard.\n"
eprint
- Description β print a comma-separated list of arguments on
stderr. - Syntax β
eprint var,stringvar,"text",... - Notes β like
printbut on the standard error file descriptor. - Notes β the error output can be re-directed with
"2>file"on the command line. - See Also β
print.
exec
- Description β replaces current
comgtprocess with another process. - Syntax β
exec "command -args..." - See Also β
system,fork.
Example:
#Finished script, call cu.
exec "cu -l "+$dev()+" -s "+$baud()
exit
- Description β terminates script execution with exit code.
- Syntax β
exit exit_code - See Also β
abort,dump.
Example:
:error
exit 1
:smeggit
exit 0
flash
- Description β toggles DTR on communication device for a specified time.
- Syntax β
flash float_constant - Notes β
float_constantis precise down to 1/100th sec. - Notes β causes modem to drop carrier or go to command mode, depending on modem settings. setting the baud rate to 0 for a time has the same effect.
- See Also β
sleep,set com.
Example:
:disconnect
flash 0.5
exit 0
fprint
- Description β print a comma-separated list of arguments in a file.
- Syntax β
fprint var,stringvar,"text",... - Notes β like
printbut appended to a file previously opened byopen. - See Also β
print.
fork
- Description β forks
comgtprocess in two. both processes continue executing the script. - Syntax β
fork - Notes β
%returns0for child process, new process ID for parent or-1for error. - See Also β
wait,kill,pid(),ppid().
Example:
fork
if % = -1 goto error
if % = 0 goto child
:parent
...
get
- Description β get string from communication device.
- Syntax β
get timeout "terminators" $string - Notes β
timeoutis a float constant,terminatorsis a list of characters that, when received, terminateget. terminators are ignored when received first. - See Also β
waitfor.
Example:
waitfor 60 "connect"
if % != 0 goto error
get 2 " ^m" $s
print "Connection parameters: ",$s,"\n"
gosub
- Description β calls a subroutine.
- Syntax β
gosub label - Notes β currently,
comgtonly supports 128 levels ofgosubcalls (enough!) - See Also β
:,goto,return.
Example:
gosub routine
sleep 1
gosub routine
goto end
:routine
print "Flim-flam!\n"
return
goto
- Description β sends execution somewhere else in the script.
- Syntax β
goto label - See Also β
:,gosub,return.
Example:
:win95
print "Today I want to go and use Linux, thank you.\n"
goto win95
hset
- Description β set the hundreds timer.
- Syntax β
hset value - Notes β this command resets the hundreds of seconds timer to a value for
htimeto start from. - See Also β
htime().
Example:
hset 0
:loop
print "Time in 1/100 of a sec.: ",htime(),"\n"
sleep 0.01
goto loop
if
- Description β tests a condition
- Syntax β
if test_condition commands... - Notes β conditionnaly executes commands if test condition is true.
- Notes β test operators are
=(equal),!=(not equal),<>(not equal to)<(less than),>(greater than),<=(less or equal),>=(greater or equal). - Notes β all operators can be used with integers and strings.
- Notes β if
test_conditionis false,ifskips to the next line. - See Also β
else.
Example:
if n>30 print "Oh-ho! too many sheep!\n" goto error
if n=17 print "Hurray! weΒ΄ve enough sheep\n" goto party
if n<17 print "Murray, get more sheep.\n" goto getmore
if $z < "Marmaluke" goto ...
if 3*a>5+b goto ...
inc
- Description β increments the content of an integer variable by 1.
- Syntax β
inc x - Notes β
xisa-zora0-z9. - See Also β
dec,let.
input
- Description β input string from keyboard into string variable.
- Syntax β
input $x - Notes β
inputterminates entry only with the ENTER key. - Notes β spaces, tabs and other funny characters are all stored in the variable.
- See Also β
set echo.
Example:
print "Enter your full name :"
input $n4
kill
- Description β sends a signal to a process.
- Syntax β
kill signal processID - Notes β both
signalandprocessIDare integer values. same as standard unixkillexcept that signal aliases are not accepted andsignalis not optional. - Notes β
0is returned in%if the signal could be sent,-1otherwise. - Notes β signal
0can be used to detect process existance. - See Also β
wait,pid(),ppid().
Example:
fork
let p=%
if p = 0 goto child
sleep 300
kill 15 p
sleep 1
kill 0 p
if % != 0 print "Child terminated\n" goto ok
print "Could not terminate child!\n"
kill 9 p
sleep 1
kill 0 p
if % = 0 print "Could not kill child!\n" goto error
print "Child killed.\n"
:ok
...
let
- Description β does a variable assignment.
- Syntax β
let x=content - Notes β
xis[$]a0-z9. - See Also β
inc,dec.
Example:
let a=5
let b=(time()-a)+5
let y7=6809
let z=0%11010111 #Binary
let z=077324 #octal
let z=0xf5b8 #hexadecimal
let $c="Daniel "
let $d=$c+" Chouinard"
let $s5="FrimpinΒ΄ Jeosaphat!"
lprint
- Description β print a comma-separated list of arguments to the log.
- Syntax β
fprint var,stringvar,"text",... - Notes β like
printbut printed like a log entry if verbose is on. logging is sent tostderr. - See Also β
print,eprint,fprint.
π Command: open
Description: opens a file or a communication device. That's it, that's the whole job. π
Syntax:
open com device, open com (stdin), open file FILE
See also: close.
Example:
open com /dev/cua1
set com 38400n81
open file "/tmp/log"
fprintf "This is a log\n"
close file
π Command: print
Description: prints a comma-separated list of arguments. Like, just yeets them to the screen.
Syntax:
print var,stringvar,"text",...
Notes: spaces and newlines are not automatically added, bestie. You want a space? You ask for the space. You want a newline? You put \n in there yourself. π€
See also: eprint, fprint, lprint.
Example:
let b=26
let $c="text variables"
print "Contstant text ",b," ",$c," time: ",$time(),"\n"
π Command: putenv
Description: sets an environment variable. very demure, very mindful, very exported. β¨
Syntax:
putenv "var=content"
Notes: environment variables are automatically exported, never returned. Child processes inherit the environment.
See also: $env().
Example:
putenv "SCRIPTDIR=/usr/lib/comgt/scripts"
system "dothat" # dothat reads env. var. SCRIPTDIR...
π Command: rem β aliases: #, //
Description: remark. Rest of the line is ignored. a little "not me, not today" for your code. π
Syntax: note that a space must follow rem.
Example:
#This is a remark
// So is this
rem This ainΒ΄t no disco.
π Command: return
Description: returns from subroutine. Go home, you're done here. π«Ά
Syntax:
return
See also: gosub.
π Command: send
Description: sends a string to the communication line (modem usually). picking up the phone and talking. π
Syntax:
send string
Notes: carriage return (ENTER) is not sent automatically β use ^m. It will not read your mind, babe.
Example:
send "atdt555-1212^m"
send $g+"^m"
send "The time is "+$time()+"^m^j"
π Command: set
Description: sets working parameters. The glow-up station for your whole session. π
Syntax:
set parameter value
Notes:
set echo on|offβ keyboard echo on-screen.set comecho on|offβ received characters echoed on-screen.set senddelay time_constantβ in-between character delay forsend.set ignorecase on|offβ case sensitivity forwaitfor. Default=on.set clocal on|offβclocal on= ignore modem signals.set umask modeβ file mode creation defaults. Seeman umask.set verbose on|offβverbose on= debug output enabled.set com com_paramsβ communication parameters, ex.:19200n81,300e71(diagram below, she's iconic).
set com com_params communication parameters.
ex.: 19200n81, 300e71
baud |||
Parity |
Data bits |
Stop bits |
Example:
set echo off
print "Password :"
input $p
print "\n"
set echo on
set comecho on
set clocal on
set senddelay 0.1
set ignorecase on
set com 38400n81
set umask 022 # Must be octal (leading zero)
...
Note on clocal:
If want your script to keep working after the carrier detect signal has dropped, set clocal on, otherwise, a CD drop causes the device line to close (hang up). This could happen if, letΒ΄s say, your script calls and connects, then disconnects or drops dtr (flash), then tries to re-connect again.
No cap, this one bites people constantly. clocal on is your bestie. π«Ά
π Command: sleep
Description: pauses execution. a lil nap break, she deserves it. π΄
Syntax:
sleep float_constant
Notes: float_constant is precise down to 1/100th sec, unless more than 100 seconds, in which case the precision falls down to 1 sec.
Example:
sleep 0.06
sleep 3
sleep 86400 /* A whole day */
π Command: system
Description: calls a system (unix) command. outsourcing the work, as one does. π
Syntax:
system "command"
See also: exec.
Example:
:dir
print "listing of directory ",$cwd(),\n"
system "ls -l |more"
π Command: testkey
Description: tests keyboard for keystroke, returns 1 in % if present. a little vibe check on your fingers. β¨οΈ
Syntax:
testkey
Notes: can only test for ENTER key. Future versions of comgt will test for more and return keycodes in %.
See also: input.
Example:
let n=1
:loop
print n," sheep... ZZZzzz...\n"
sleep n
inc n
testkey
if % = 0 goto loop
π Command: wait
Description: wait for a child process to terminate. sitting there, patiently, like a good friend at the bus stop. π
Syntax:
wait
Notes: process ID of terminated child is returned in %.
See also: fork, kill.
Example:
fork
let p=%
if p=0 goto child
if p=-1 goto error
print "Waiting for child to finish..."
wait
print "\n"
if %!=p print "Wait got wrong PID!\n" goto error
print "Child is done.\n"
π Command: waitfor
Description: waits until one of a list of strings is received. it's giving "I'll know it when I see it". π₯
Syntax:
waitfor timeout "string1","string2","string3"...
Notes: timeout is a floating time constant. waitquiet returns 0 for the first string received, 1 for the second, etc⦠and -1 for a timeout. Case is ignored by default unless ignorecase is set to off.
See also: get.
Example:
:dial
send "atdt555-4411^m"
waitfor 60 "no carrier","busy","no dial tone","connect"
if % = -1 goto timedout
if % = 0 goto nocd
if % = 1 goto redial
if % = 2 goto error
if % = 3 goto connected
π Command: waitquiet
Description: waits until communication line stops receiving for a time. the "shhh, let them finish talking" of serial comms. π€«
Syntax:
waitquiet timeout quiettime
Notes: both timeout and quiettime are floating time constants with 1/100th sec. accuracy. Usefull for "swallowing" incoming characters for a while or waiting for an unknown prompt.
Example:
:closecon
send "logoff^m"
waitquiet 10 0.5
send "yes^m"
β Integer functions β
these bad girls return a number into your %β¦ no wait, into your let x=. either way, slay. π
π I-Function: access
Description: verifies access rights to a file.
Syntax:
let x=access("/tmp/file","frwx")
Notes: the second string contains one or more of Β΄fΒ΄,Β΄rΒ΄,Β΄wΒ΄,Β΄xΒ΄ to respectively check existence, read, write and execute permissions. Under root id, the only useful check is Β΄fΒ΄, as all others will return true.
Return value: 0 if the file exists, is readable, writable, executable, or -1 if not.
See also: man access(2)
π I-Function: baud
Description: returns current baudrate of communication line.
Syntax:
let x=baud()
Notes: does not necessarily match the modem connection speed.
See also: $baud().
π I-Function: len
Description: returns the length of a string.
Syntax:
let x=len($s)
Notes: "" is zero. Strings currently have a maximum length of 1024 characters. comgt doesnΒ΄t handle string overflow at all.
β οΈ Like, at all. Don't push her past 1024 or she will simply not cope. π
π I-Function: htime
Description: returns hundreds of seconds since start of script.
Syntax:
let x=htime()
Notes: set to a specific value with hset.
See also: hset.
π I-Function: pid
Description: returns process ID number of current process (comgt).
Syntax:
let x=pid()
See also: ppid(), fork
π I-Function: ppid
Description: returns process ID number of parent process.
Syntax:
let x=ppid()
Notes: can be used by forked child to detect parent process.
π I-Function: time
Description: returns time in seconds since Jan 1, 00:00:00 1970 GMT.
Syntax:
let x=time()
Notes: used to calculate time differences.
See also: $time()
π I-Function: val
Description: returns value of string.
Syntax:
let x=val($x)
Notes: string is not an expression; must only contain [0-9] characters. Future versions of comgt will be able to evaluate expressions. (Maybe) (This was written 6 years ago.)
Not the "(This was written 6 years ago.)" π the manpage is self-aware, we love a legend who keeps receipts.
π I-Function: verbose
Description: returns value of verbose setting.
Syntax:
let x=verbose()
Notes: 0=off, 1=on.
π¦ String functions π¦
the ones that hand you back a $string instead of a number. pretty AND functional. π
πΈ S-Function: basename
Description: returns basename part of path.
Syntax:
let $x=$basename($p)
Notes: $basename("/usr/bin/more")="more"
See also: $dirname().
πΈ S-Function: baud
Description: returns string representation of current baud rate.
Syntax:
let $x=$baud()
Notes: defined by set com
See also: baud(), set com.
πΈ S-Function: cwd
Description: returns current working directory pathname.
Syntax:
let $x=$cwd()
See also: cd.
πΈ S-Function: dev
Description: returns current communication device pathname.
Syntax:
let $x=$dev()
Notes: defined by -d command line argument or open com
See also: open com.
πΈ S-Function: dirname
Description: returns directory name part of path.
Syntax:
let $x=$dirname($p)
Notes: $dirname("/usr/bin/more")="/usr/bin"
See also: $basename().
πΈ S-Function: env
Description: returns content of an environment variable.
Syntax:
let $x=$env("HOME")
Notes: non-existant variables return an empty string.
See also: putenv.
πΈ S-Function: hex
Description: converts value to hexadecimal representation.
Syntax:
let $x=$hex(x)
Notes: letters a-f in lowercase, no preceding 0x
See also: $hexu(), $oct().
πΈ S-Function: hexu
Description: converts value to hexadecimal representation.
Syntax:
let $x=$hex(x)
Notes: letters A-F in uppercase, no preceding 0x
See also: $hex(), $oct().
π«Ά S-Function: hms
- Description β turns a number of seconds into a time string, iconic behaviour honestly β¨
- Syntax β
let $x=$hms(x) - Notes β the format is
"HH:MM:SS", which is so useful for chronometer displays π - Notes β use it with
"time()", and do not try to increment a variable every second using"sleep 1"(peep the ISP script example for how it's really done, bestie) - Notes β heads up: the format becomes
"HHH:MM:SS"once you pass 99 hours, 59 minutes, 59sβ¦ π - See Also β
time().
πΈ S-Function: left
- Description β hands you the left portion of a string, no cap
- Syntax β
let $x=$left($s,l) - Notes β
$s=Source string,l=length - Notes β
lmust be less than the length of the string, fr fr - See Also β
$right(),$mid().
π S-Function: mid
- Description β returns the midsection of a string π¦
- Syntax β
let $x=$mid($s,s,l) - Notes β
$s=Source string,s=start,l=length - Notes β
smust be less than the length of the string, andlcan be some huge number (9999) to grab the right side of a string all the way to the end - Notes β plot twist: the first character of a string is position
0, not1π - See Also β
$right(),$left().
π§ S-Function: oct
- Description β converts a value to its octal representation
- Syntax β
let $x=$oct(x) - See Also β
$hex(),$hexu().
π S-Function: right
- Description β returns the right portion of a string
- Syntax β
let $x=$right($s,l) - Notes β
$s=Source string,l=length - Notes β
lmust be less than the length of the string - See Also β
$left(),$mid().
π S-Function: rpipe
- Description β returns the first line from a system piped command π₯
- Syntax β
let $x=$rpipe("/bin/ls |grep myfile") - Notes β not very useful unless you use it with
head,tail,grep, etcβ¦ - See Also β
system.
β S-Function: time
- Description β returns a 24 character local time string
- Syntax β
let $x=$time() - See Also β
time(). - Notes β time is in this format:
Mon Apr 8 14:21:22 1996
012345678901234567890123
1 2
π S-Function: tolower
- Description β returns a lowercaseΒ΄d string
- Syntax β
let $x=$tolower($y)
π S-Function: toupper
- Description β returns an uppercaseΒ΄d string
- Syntax β
let $x=$toupper($y)
π Test operators π
=β equal βif 1+2=3β yes β!=β not equal βif 1+2!=3β no<>β not equal βif 1+2<>3β no>β Greater than βif 1+3>3β yes β<β Less than βif 1+3<3β no>=β Greater or equal βif 3>=3β yes β<=β Greater or equal βif 2<=3β yes β
Strings can be compared using the same operators, periodt. Like:
"aaa" < "aab", "aaaa" > "aaa", "Test" != "test", "One" = "One", "A" > "a", "Fumble" <= "Fumigate", "Farsical" <> "Comedic"
Note that "set ignorecase on" does NOT apply to string comparisons. Nope. Not even a little. π€
β¨ Expression operators β¨
+β Addition βlet a=2+2β4+β Concatenation βlet $b="aa"+"bb"β"aabb"-β Substraction βlet e=2-5β-3*β Multiplication βlet f=11*2β22/β Division βlet g=34/11β3&β Bit-Wise AND βlet h=42&7β2|β Bit-Wise OR βlet a=42|5β47^β Bit-Wise XOR βlet a=42^7β45
Mixed expression examples π
#Returns number of seconds since 00:00:00
let $t=$time() #Take a snapshot.
let a=(val(mid$($t,11,2))*3600)+(val(mid$($t,14,2))*60)+val(mid$($t,17,2))
#Notice the extra sets of parenthesis because comgtΒ΄s expression
#evaluator is brain-dead.
#For example, 5-2+1 should give you 4, right? Well, according to
#getvalue(), it actually gives 2, because it does it somewhat from
#right to left.
#So to evaluate 5-2+1 correctly, use (5-2)+1. If youΒ΄re using
#simple, two-element calculations, donΒ΄t worry about it.
#5-2 will give you 3.
#Concatenation (Calls cu)
exec "cu -l "+$dev()+" -s "+$baud()
#In a test condition
if a+c > strlen($c) goto toomuch
#String comparison
let $t=$mid($time(),11,8)
if $t > "19:59:59" print "Too late for that!\n" goto toolate
if $t < "08:00:00" print "Too early!\n" goto tooearly
if $t = "00:00:00" print "Oh god! ItΒ΄s Twinkee time!\n"
π KNOWN FEATURES π
The getvalue() parser. It makes me laugh so I think IΒ΄ll leave it that way. β Daniel.Chouinard@pwc.utc.com
πΈ ENVIRONMENT VARIABLES πΈ
COMGTPINβ the 4 digit pin of the SIM, for use by the PIN scriptCOMGTAPNβ the APN to write to the data card, used by the APN script
π AUTHORS π
Daniel.Chouinard <Daniel.Chouinard@pwc.utc.com> wrote the original dcon utility. Respect the OG π«‘
Paul Hardwick <paul@peck.org.uk> updated it for the latest compilers, provided the built-in script functionality and tested it against GPRS and 3G datacards.
Martin Gregorie <martin@gregorie.org> wrote the original manpage for comgt from the dcon documentation and packaged comgt for distribution.
π History
Daniel Chouinard wrote most (90%) of dcon back in 1989, when he started doing Unix Apps tech support mostly by modem to customer systems. He was tired of typing all those passwords and funny call-charging codes everytime he used cu. Also, the company he worked for needed a system that would log call times and estimated costs. Thus dcon was born. Six or seven years later (1996) and he was using pppd to connect to his ISP site. He was more or less happy with chat but found it lacked flow control and multiple response checks from "atdt...". He wanted it to do different things for "no carrier", "no dial tone", and "busy". Although he thought that chat would probably be enhanced someday, when he found dcon.c on one of his old 45M tapes he tried compiling it on his Linux box and, lo and behold, it did. In the end, he added a few things to it (kill, fork, wait, 1/100 sec. times) and left it at that.
A couple of years ago Paul Hardwick found the program, dcon 0.97, last modified in 1996. The purpose of this program was to run scripts that would control Linux serial ports. The implementation was very similar to something he had written for Windows. Anyway, rather than reinvent he contacted the author, Daniel Chouinard, and asked his permission to reuse the code. Happily he gave permission and a basic but useful utility called comgt was created. Paul takes no credit for the engine, apart from making it compatible with todays compilers. It is basically dcon repackaged.
okay bestie that's the whole page!! π this version is the one from 20 October, 2006, and yeah, it's comgt(1) β go forth and dial, mwah π
β¨
π¦ where this page comes from
- debian bookworm: comgt 0.32-4
- debian trixie: comgt 0.32-6
- ubuntu jammy: comgt 0.32-3
- ubuntu noble: comgt 0.32-4
- ubuntu resolute: comgt 0.32-6
- ubuntu stonking: comgt 0.32-6
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms