SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG

BotDetect - Real-Time Bot Detection API
 
 

MAN page from PLD comgt-0.32-1.i686.rpm

comgt

Section: User Commands (1)
Updated: 20 October, 2006
Index 

NAME

comgt - Option GlobeTrotter GPRS/EDGE/3G/HSDPA and Vodafone 3G/GPRS datacard control tool 

SYNOPSIS

comgt-ddevice -ehstvVxscript 

OPTIONS

-d deviceset the device to be used to communicate with the data-card. If not specified then comgt trys/dev/noz2, /dev/ttyUSB2and then

-e turn on serial communications echo.

-h display summary help and exit.

-sdon't run the internal default script before an external script.

-tchange to an alternate line terminator (default ").

-v run in verbose mode. This traces scripts as they are executed. It is intended to help in debugging scripts.

-V Print Version information.

-xfor internal and external scripts, any reference to 115200 baud is converted to 57600.This is useful for data cards that don't like 115200 baud such as the GlobeTrotter EDGE.

 

DESCRIPTION

comgt is a scripting language interpreter useful for establishingcommunications on serial lines and through PCMCIA modemsas well as GPRS and 3G datacards.

comgt has some features that are rarely found in other utilities of the same type. 

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 as well as Vodafone 3G. It can set the PIN and display information about datacards before a PPP connection is started.Additionally, because the GlobeTrotter and Vodafone 3G/GPRS datacard have a secondary serial interface, these datacards can be monitored while a PPP connection is in existence and transferring data.

comgtis primarily designed to work with the GlobeTrotter range of datacards but should be compatible with any other GPRS or 3G datacard provided its interface is implemented as one or more serial or USB serial devices and it is controlled and queried by an implementation of the Hayes command interface with the same AT command extensions used by the listeddatacards.  

Using comgt

comgt has only one function: to run a script. This may be one of a number of "standard" internal scripts or an external script. Both types of script areinvoked in the same way. The "standard" scripts are built into comgtand will work for serially connected modems, built-in modems, PCMCIA modemsas well as the GlobeTrotter GPRS and the Vodafone 3G/GPRS datacards.There is a search priority order for scripts - 1)internal, 2)working directory, 3)/usr/share/comgt

 

Built-in scripts

comgtThis runs the default internal script. Runningcomgtwithout any script specified, e.g., comgt -d /dev/ttyS1 it will check for a PIN and prompt you if it is required. The next thing it does is wait for thedevice to register, it then reports the signal strength.If you don't specify a port with the -d option then /dev/modem is assumed.If the -s switch is not used then this default script is run before any external script.

comgt help Lists these and the other options available.

comgt info Lists the datacard configuration.

comgt sig Prints the signal strength.

comgt regPrints the registration state.

comgt 3GPuts a GlobeTrotter 3G/Fusion and Vodafone 3G into 3G network only mode (UMTS/HSDPA).

comgt 2GPuts a GlobeTrotter 3G/Fusion and Vodafone 3G into 2G network only mode (GSM/GPRS/EDGE).

comgt 3G2GPuts a GlobeTrotter 3G/Fusion and Vodafone 3G into 3G preferred mode (UMTS/HSDPA and GSM/GPRS/EDGE).

comgt GTEDGEUse this command to initialise GlobeTrotter EDGE and GlobeTrotter Combo EDGE cards before doing anything else. (It switches on the radio).

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 built in scripts you can make your own. The followingscript 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

If you needed to specify the port as well then do this:

comgt -d /dev/ttyS1 GPRS

You can also pass environment parameters to acomgt script via $env().

 

Replacing chat

chat is a utility that comes with the ppp package (for Linux, anyway) that,with a set of expect-send string couples, does enough to connect most peopleto ISPs and such. While chat's use is very simple, it isn't very flexible.That's where comgt takes over.

comgt can be used in place of chatusing the same strategy. For example, a pppdline 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 morefunctional by adding code for busy detect, re-dialing, etc... 

Verbose output

When the verbose option is turned on, comgt reports everthing onthe standard error channel.If turned on from the command line (-v), the output contains 4 sections.

- Command line argument actionsThese are actions taken because they were specified from the command line, such as opening a communication device (-d), etc...For these to be output, you must specify -v as the first argument.

- List of argumentsThe 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 listA 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 outputList of commands as they are executed. The parser prints the line its currently on, starting from the exact point where its 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, eprint or lprint.)

Here's an example:

$ comgt -v -d/dev/cua1 -s blah.scrcomgt 00:18:46 -> Verbose output enabledcomgt 00:18:46 -> Script file: blah.scrcomgt 00:18:46 -> argc:5comgt 00:18:46 -> argv[0]=comgtcomgt 00:18:46 -> argv[1]=-vcomgt 00:18:46 -> argv[2]=-d/dev/cua1comgt 00:18:46 -> argv[3]=-scomgt 00:18:46 -> argv[4]=blah.scrcomgt 00:18:46 ->  ---Script---1@0000 set com 38400n81 let a=22@0025 print "9x",a,"=",9*a,"\n"3@0051 sleep 54@0059 exit 0comgt 00:18:46 ->  ---End of script---comgt 00:18:46 -> @0000 set com 38400n81 let a=2comgt 00:18:46 -> @0017 let a=2comgt 00:18:46 -> @0025 print "9x",a,"=",9*a,"\n"9x2=18comgt 00:18:46 -> @0051 sleep 5comgt 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 terminatedby newline characters (Unix standard.) Scripts can be created and/or modifiedusing any standard text editor (vi, vim, joe, pico, emacs, ed, microEmacs)Lines in a comgtscript 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+76This is not: let n= x + 76  Because this space ^ would terminate the let command group.
 

Error reporting

When comgtdetects a script error, it immediately turns on verbose mode,generates a dump (see the dump command), reports the error in three linesand stops the execution. The first line reported is the command groupbeing executed, the second one shows where the parser got and the thirdline reports the character position of the program counter, the error andthe exit code.

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 enabledcomgt 11:20:15 -> Script file: blar2.scrcomgt 11:20:15 -> argc:3comgt 11:20:15 -> argv[0]=comgtcomgt 11:20:15 -> argv[1]=-vscomgt 11:20:15 -> argv[2]=blar2.scrcomgt 11:20:15 ->  ---Script---1@0000 inc n2@0007 dec d33@0015 let a=58/34@0027 let $d="fod"5@0041 let c=1/06@0052 let $y4="sdfgsdfgsdfg"comgt 11:20:15 ->  ---End of script---comgt 11:20:15 -> @0000 inc ncomgt 11:20:15 -> @0007 dec d3comgt 11:20:15 -> @0015 let a=58/3comgt 11:20:15 -> @0027 let $d="fod"comgt 11:20:15 -> @0041 let c=1/0comgt 11:20:15 -> -- Error Report --comgt 11:20:15 -> ---->         ^comgt 11:20:15 -> Error @49, line 5, Division by zero. (6)
 

Exit codes

When comgtterminates, it does so with an "exit code". That is a number passedback to the calling process to signify success or failures. In every-dayUnix, 0 (zero) means success and everything else means whatever the authorof the program wants it to mean. In a shell script, or directly on the commandline, you may look at the content of $? after having called comgtto examine its exit code.

Example:

#!/bin/shcomgt /root/bin/call-ispif [ $? != 0 ]; then  echo "Oops! Something went wrong."fi

Internal comgterror codes are as follows:

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/sh or some such)
 

Commands

Command     : :   Alias: labelDescription : Notes an anchor point for goto or gosub to branch to.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"              returnCommand     : abortDescription : Causes comgt to call abort() and produce a core dump.Syntax      : abortSee Also    : dump, exit.Command     : cdDescription : Change directory.Syntax      : cd directoryNotes       : -1 is returned in % if the change could not be made.Notes       : directory is a string and thus could be a variable.See Also    : $cwd().Example:              cd "duh"              if % != 0 print "Could not cd into duh.\n"Command     : closeDescription : closes file previously opened with open.Syntax      : close fileSee Also    : open.Command     : decDescription : Decrements the content of an integer variable by 1.Syntax      : dec xNotes       : x is from a to z or a0 to z9.Notes       : Note that "let x=x-1" also works.See Also    : let, inc.Command     : dumpDescription : Lists all non-zero integer variables and modified stringDescription : variables as log entries (standard error channel.)Syntax      : dumpSee Also    : abort, exitCommand     : elseDescription : Alternatively execute commands if last "if" tested false.Syntax      : else commands...See Also    : ifExample:              if w<350 print "Wow! Imagine that.\n"              else print "Rush Limbaugh is a big fat bastard.\n"Command     : eprintDescription : print a comma-separated list of arguments on stderr.Syntax      : eprint var,stringvar,"text",...Notes       : Like print but on the standard error file descriptor.  Notes       : The error output can be re-directed with "2>file" on Notes       : the command line.See Also    : print.Command     : execDescription : Replaces current comgt process with another process.Syntax      : exec "command -args..."See Also    : system, fork.Example:              #Finished script, call cu.              exec "cu -l "+$dev()+" -s "+$baud()Command     : exitDescription : terminates script execution with exit code.Syntax      : exit exit_codeSee Also    : abort, dump.Example:              :error              exit 1              :smeggit              exit 0Command     : flashDescription : Toggles DTR on communication device for a specified time.Syntax      : flash float_constantNotes       : float_constant is precise down to 1/100th sec.Notes       : Causes modem to drop carrier or go to command mode, Notes       : depending on modem settings.  Setting the baud rate to 0 Notes       : for a time has the same effect.See Also    : sleep, set com.Example:              :disconnect              flash 0.5              exit 0Command     : fprintDescription : print a comma-separated list of arguments in a file.Syntax      : fprint var,stringvar,"text",...Notes       : Like print but appended to a file previously opened Notes       : by open.See Also    : print.Command     : forkDescription : forks comgt process in two.  Both processes continue Description : executing the script.Syntax      : forkNotes       : % returns 0 for child process, new process ID for Notes       : parent or -1 for error.See Also    : wait, kill, pid(), ppid().Example:              fork              if % = -1 goto error              if % = 0 goto child              :parent              ...Command     : getDescription : get string from communication device.Syntax      : get timeout "terminators" $stringNotes       : timeout is a float constant, terminators is a Notes       : list of characters that, when received, terminate Notes       : get.  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"Command     : gosubDescription : calls a subroutine.Syntax      : gosub labelNotes       : Currently, comgt only supports 128 levels of gosub Notes       : calls (enough!)See Also    : :, goto, return.Example:              gosub routine              sleep 1              gosub routine              goto end              :routine              print "Flim-flam!\n"              returnCommand     : gotoDescription : Sends execution somewhere else in the script.Syntax      : goto labelSee Also    : :, gosub, return.Example:              :win95              print "Today I want to go and use Linux, thank you.\n"              goto win95Command     : hsetDescription : Set the hundreds timer.Syntax      : hset valueNotes       : This command resets the hundreds of seconds timer to Notes       : a value for htime to start from.See Also    : htime().Example:              hset 0              :loop              print "Time in 1/100 of a sec.: ",htime(),"\n"              sleep 0.01              goto loopCommand     : ifDescription : tests a conditionSyntax      : if test_condition commands...Notes       : Conditionnaly executes commands if test condition is true.Notes       : Test operators are = (equal), != (not equal), Notes       : <> (not equal to) < (less than), > (greater than), Notes       : <= (less or equal), >= (greater or equal).  Notes       : All operators can be used with integers and strings.  Notes       : If test_condition is false, if skips toNotes       : 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 ...Command     : incDescription : increments the content of an integer variable by 1.Syntax      : inc xNotes       : x is a-z or a0-z9.See Also    : dec, let.Command     : inputDescription : input string from keyboard into string variable.Syntax      : input $xNotes       : input terminates entry only with the ENTER key.  Notes       : Spaces, tabs and other funny characters are all Notes       : stored in the variable.See Also    : set echo.Example:              print "Enter your full name :"              input $n4Command     : killDescription : Sends a signal to a process.Syntax      : kill signal processIDNotes       : Both signal and processID are integer values.  Same as Notes       : standard unix kill except that signal aliases are not Notes       : accepted and signal is not optional.Notes       : 0 is returned in % if the signal could be sent, -1 Notes       : otherwise.Notes       : Signal 0 can 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              ...Command     : letDescription : Does a variable assignment.Syntax      : let x=contentNotes       : x is [$]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!"Command     : lprintDescription : Print a comma-separated list of arguments to the log.Syntax      : fprint var,stringvar,"text",...Notes       : Like print but printed like a log entry if verbose is on.Notes       : logging is sent to stderr.See Also    : print, eprint, fprint.Command     : openDescription : Opens a file or a communication device.Syntax      : open com device, open com (stdin), open file FILESee Also    : close.Example:              open com /dev/cua1              set com 38400n81              open file "/tmp/log"              fprintf "This is a log\n"              close fileCommand     : printDescription : print a comma-separated list of arguments.Syntax      : print var,stringvar,"text",...Notes       : Spaces and newlines are not automatically added.See Also    : eprint, fprint, lprint.Example:              let b=26              let $c="text variables"              print "Contstant text ",b," ",$c," time: ",$time(),"\n"Command     : putenvDescription : Sets an environment variable.Syntax      : putenv "var=content"Notes       : Environment variables are automatically exported, Notes       : never returned. Children processes inherit the Notes       : 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 line is ignored.Syntax      : Note that a space must follow "rem".Example:              #This is a remark              // So is this              rem This ain't no disco.Command     : returnDescription : Returns from subroutine.Syntax      : returnSee Also    : gosub.Command     : sendDescription : sends a string to the communication line (modem usually).Syntax      : send stringNotes       : Carriage return (ENTER) is not sent automatically Notes       : (use ^m).Example:              send "atdt555-1212^m"              send $g+"^m"              send "The time is "+$time()+"^m^j"Command     : setDescription : sets working parameters.Syntax      : set parameter valueNotes       :Command                       Description----------------------------- -------------------------------------------------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 for "send"set ignorecase on|off         Case sensitivity for "waitfor".                               Default=on.set clocal on|off             clocal on = ignore modem signalsset umask mode                file mode creation defaults.                               See man umask.set verbose on|off            verbose on = debug output enabled.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.Command     : sleepDescription : Pauses execution.Syntax      : sleep float_constantNotes       : Float_constant is precise down to 1/100th sec, unlessNotes       : more than 100 seconds, in which case the precision Notes       : falls down to 1 sec.Example:              sleep 0.06              sleep 3              sleep 86400 /* A whole day */Command     : systemDescription : Calls a system (unix) commandSyntax      : system "command"See Also    : exec.Example:              :dir              print "listing of directory ",$cwd(),\n"              system "ls -l |more"Command     : testkeyDescription : Tests keyboard for keystroke, returns 1 in % if present.Syntax      : testkeyNotes       : Can only test for ENTER key.  Future versions of comgt Notes       : 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 loopCommand     : waitDescription : Wait for a child process to terminate.Syntax      : waitNotes       : 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     : waitforDescription : Waits until one of a list of strings is receivedSyntax      : waitfor timeout "string1","string2","string3"...Notes       : Timeout is a floating time constant.  waitquiet returnsNotes       : 0 for the first string received, 1 for the second, etc...Notes       : and -1 for a timeout.  Case is ignored by default unlessNotes       : 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 connectedCommand     : waitquietDescription : Waits until communication line stops receiving for a time.Syntax      : waitquiet timeout quiettimeNotes       : Both timeout and quiettime are floating time constantsNotes       : with 1/100th sec. accuracy.  Usefull for "swallowing" Notes       : incoming characters for a while or waiting for an Notes       : unknown prompt.Example:              :closecon              send "logoff^m"              waitquiet 10 0.5              send "yes^m"
 

Integer functions

I-Function  : AccessDescription : Verifies access rights to a fileSyntax      : let x=access("/tmp/file","frwx")Notes       : The second string contains one or more of Notes       : 'f','r','w','x' to repectively check Notes       : existence, read, write and execute permissions.  Notes       : Under root id, the only useful check is 'f', asNotes       : all others will return true.Return Value: 0 if the file exists, is readable, writable, Return Value: executable, or -1 if not.See Also    : man access(2)I-Function  : baudDescription : Returns current baudrate of communication line.Syntax      : let x=baud()Notes       : Does not necessarily match the modem connection speed.See Also    : $baud().I-Function  : lenDescription : Returns the length of a string.Syntax      : let x=len($s)Notes       : "" is zero.  Strings currently have a maximum length ofNotes       : 1024 characters. comgt doesn't handle string overflow Notes       : at all.I-Function  : htimeDescription : 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  : pidDescription : Returns process ID number of current process (comgt)Syntax      : let x=pid()See Also    : ppid(), forkI-Function  : ppidDescription : Returns process ID number of parent process.Syntax      : let x=ppid()Notes       : Can be used by forked child to detect parent Notes       : process.I-Function  : timeDescription : 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  : valDescription : Returns value of string.Syntax      : let x=val($x)Notes       : String is not an expression; must only contain [0-9]Notes       : characters. Future versions of comgt will be able to Notes       : evaluate expressions. (Maybe) (This was written 6 Notes       : years ago.)I-Function  : verboseDescription : Returns value of verbose setting.Syntax      : let x=verbose()Notes       : 0=off, 1=on.
 

String functions

S-Function  : basenameDescription : Returns basename part of path.Syntax      : let $x=$basename($p)Notes       : $basename("/usr/bin/more")="more"See Also    : $dirname().S-Function  : baudDescription : Returns string representation of current baud rate.Syntax      : let $x=$baud()Notes       : Defined by "set com"See Also    : baud(), set com.S-Function  : cwdDescription : Returns current working directory pathname.Syntax      : let $x=$cwd()See Also    : cd.S-Function  : devDescription : 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  : dirnameDescription : Returns directory name part of path.Syntax      : let $x=$dirname($p)Notes       : $dirname("/usr/bin/more")="/usr/bin"See Also    : $basename().S-Function  : envDescription : Returns content of an environment variableSyntax      : let $x=$env("HOME")Notes       : Non-existant variables return an empty string.See Also    : putenv.S-Function  : hexDescription : Converts value to hexadecimal representationSyntax      : let $x=$hex(x)Notes       : Letters a-f in lowercase, no preceding "0x"See Also    : $hexu(), $oct().S-Function  : hexuDescription : Converts value to hexadecimal representationSyntax      : let $x=$hex(x)Notes       : Letters A-F in uppercase, no preceding "0x"See Also    : $hex(), $oct().S-Function  : hmsDescription : Converts number of seconds into time stringSyntax      : let $x=$hms(x)Notes       : Format is "HH:MM:SS".  Useful for chronometer displaysNotes       : Use with "time()", do not try to increment a variable Notes       : every second using "sleep 1".  (See ISP script example)Notes       : Format becomes "HHH:MM:SS" after 99 hours, 59 minutes, Notes       : 59s...See Also    : time().S-Function  : leftDescription : Returns left portion of a stringSyntax      : let $x=$left($s,l)Notes       : $s=Source string, l=lengthNotes       : l must be less than the length of the string.See Also    : $right(), $mid().S-Function  : midDescription : Returns midsection of a string.Syntax      : let $x=$mid($s,s,l)Notes       : $s=Source string, s=start, l=lengthNotes       : s must be less than the length of the string, l can beNotes       : some huge number (9999) to return the right side of a Notes       : string to the end.  the first character of a string is Notes       : position 0, not 1.See Also    : $right(), $left().S-Function  : octDescription : Converts value to octal representation.Syntax      : let $x=$oct(x)See Also    : $hex(), $hexu().S-Function  : rightDescription : Returns right portion of a string.Syntax      : let $x=$right($s,l)Notes       : $s=Source string, l=lengthNotes       : l must be less than the length of the string.See Also    : $left(), $mid().S-Function  : rpipeDescription : Returns the first line from a system piped commandSyntax      : let $x=$rpipe("/bin/ls |grep myfile")Notes       : Not very useful unless used with head, tail, grep, Notes       : etc...See Also    : system.S-Function  : timeDescription : Returns 24 character local time stringSyntax      : let $x=$time()See Also    : time().Notes       : Time is in this format: Mon Apr  8 14:21:22 1996                                      012345678901234567890123                                                1         2S-Function  : tolowerDescription : Returns lowercase'd string.Syntax      : let $x=$tolower($y)S-Function  : toupperDescription : Returns uppercase'd string.Syntax      : let $x=$toupper($y)
 

Test operators

Operator Description       Example       Result=        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       yesStrings can be compared using the same operators."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. 

Expression operators

Operator  Description      Example           Result+         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:00let $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 conditionif a+c > strlen($c) goto toomuch#String comparisonlet $t=$mid($time(),11,8)if $t > "19:59:59" print "Too late for that!\n" goto toolateif $t < "08:00:00" print "Too early!\n" goto tooearlyif $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.ChouinardAATTpwc.utc.com 

ENVIRONMENT VARIABLES

COMGTPIN - the 4 digit pin of the SIM for use by PIN scriptCOMGTAPN - the APN to write to the data card, used by the APN script. 

AUTHORS

Daniel.Chouinard <Daniel.ChouinardAATTpwc.utc.com> wrote the originaldconutility.

Paul Hardwick <paulAATTpeck.org.uk> updated it for the latest compilers, provided the built-in script functionality and tested it against GPRS and 3G datacards.

Martin Gregorie <martinAATTgregorie.org> wrote the original manpage forcomgt from thedcondocumentation and packaged comgtfor distribution. 

History

DanielChouinard wrote most (90%) of dcon back in 1989 when he started doing Unix Apps tech support mostly by modem to customersystems. He was tired of typing all those passwords and funny call-chargingcodes everytime he used cu. Also, the company he worked for needed a systemthat would log call times and estimated costs. Thus dcon was born.Six or seven years later (1996) and he was using pppd to connect tohis 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 theprogram,dcon 0.97, last modified in 1996. The purpose of thisprogram was to run scripts that would control Linux serial ports. Theimplementation was very similar to something he had written forWindows. Anyway, rather than reinvent he contacted the author, DanielChouinard, and asked his permission to reuse the code.Happily he gave permission and a basic but useful utilitycalled comgt was created. Paul takes no credit for the engine, apart from making it compatible with todays compilers.It is basically dcon repackaged.


 

Index

NAME
SYNOPSIS
OPTIONS
DESCRIPTION
Features
Supported GPRS and 3G datacards
Using comgt
Built-in scripts
Custom Scripts
Replacing chat
Verbose output
Programming manual
Syntax
Error reporting
Exit codes
Commands
Integer functions
String functions
Test operators
Expression operators
KNOWN FEATURES
ENVIRONMENT VARIABLES
AUTHORS
History

This document was created byman2html,using the manual pages.
 
ICM Bot detect detector