Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #221062

Re: Microcom; What's this Script Feature?

From Dan Ritter <dsr@randomstring.org>
Newsgroups linux.debian.user
Subject Re: Microcom; What's this Script Feature?
Date 2020-04-07 15:50 +0200
Message-ID <zSWM2-dG-7@gated-at.bofh.it> (permalink)
References <zSW9j-8sG-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Martin McCormick wrote: 
> * x - execute a script
> 
> 	Everything seems to work as far as I can tell but what
> does a script look like?

man runscript

> 	The unix convention of typing the Up-Arrow and starting
> microcom is very handy since one does not have to type
> 
> microcom -f -p/dev/ttyUSB4 -s9600
> each time.  Actually, I usually get away with !mic followed by
> Enter and it starts.  Good work to everybody who created this
> useful little terminal program.

Time to learn the awesome power of Linux.

Three ways to do this:

1. shell script

Create a text file with the following two lines of code:

#!/bin/sh
exec microcom -f -p/dev/ttyUSB4 -s9600

Name it something short and memorable, like serial

Then

chmod a+rx serial

And from then on, it's a program you can run.

2. shell alias

Most shells have aliases available. In bash, you can stick them
in your .bashrc file. Add this line:

alias serial='microcom -f -p/dev/ttyUSB4 -s9600'

and then re-evaluate your .bashrc (which is done automatically
on login):

. .bashrc

Now you have a new command.

3. shell function

Most shells have functions available, too. The difference
between an alias and a function is that an alias is just a
substitution, but a function can take arguments and perform
complicated feats of logic. In this case, a function is
overkill, but it's still easy to drop in to your .bashrc.

function serial {
    microcom -f -p/dev/ttyUSB4 -s9600 
}


There you go.

-dsr-

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Microcom; What's this Script Feature? "Martin McCormick" <martin.m@suddenlink.net> - 2020-04-07 15:10 +0200
  Re: Microcom; What's this Script Feature? Dan Ritter <dsr@randomstring.org> - 2020-04-07 15:50 +0200
  Re: Microcom; What's this Script Feature? Reco <recoverym4n@enotuniq.net> - 2020-04-07 16:10 +0200
    Re: Microcom; What's this Script Feature? "Martin McCormick" <martin.m@suddenlink.net> - 2020-04-07 18:50 +0200

csiph-web