[Sussex] Future Talk [Was: Label and partition external hard drive]

Desmond Armstrong desmond.armstrong at gmail.com
Sat Feb 26 10:28:00 UTC 2011


  On 26/02/11 10:05, Steve Dobson wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi Desmond
>
> I've started a new thread for this as we are now well away from the
> original topic.
>
> On 25/02/11 21:03, Desmond Armstrong wrote:
>> I have an idea for you to present.
>> What I think would be very helpful is to choose some fairly small CLI
>> function and then to build perhaps using Python some sort of GUI for
>> it. In this way we can appreciate the build up of these functions.
> Nice idea, but not something I could present as that is not the way I
> work.  I've never used Python, and it is also not the way that you gain
> the power of the CLI.
>
> When Apple produced OSX I jumped for joy!  There were a lot of old CLI
> diehards that where claiming that you could not, no way, not in a
> million years, produce a GUI for *nix administration.  Apple had just
> proved them wrong.
>
> Now a few years later we have a rich set of GUI system admin tasks, at
> least I do in Gnome, and I doubt that there aren't equivalents in KDE.
> I doubt that there is any single task that one can do on the CLI that
> doesn't have a GUI app somewhere.
>
> If you want to do one task then I would say that a good GUI is easier
> (and probably quicker).  I use to use cdrecord to burn my ISO images,
> now I use Brasero.  Even for a CLI hacker like me Brasero is quicker to
> use.  And that it's the only case.  I use RhythmBox now for ripping my
> CDs (ripit is the command line tool I use to use).  The list goes on.
>
> I've said it before but I will say it again: The power of the CLI comes
> from chaining commands together!
>
>> I think this sort of presentation coming from somebody well versed in
>> the CLI such as yourself would be very instructive. It would also be
>> very helpful to those who are not continuously doing CLI and
>> consequently will normally be quite error prone.
> If I were to give a talk it would more likely be on the lines of how to
> approach command line scripting and the power of the pipe!  I would do
> it by example.  Here is an example from the real world.
>
> I was consulting on a warehouse management software installation a few
> years back.  Every so often we needed to take the system over for
> software updates, database fixes and the like.  To do this we first had
> to kick off all the users (packers) out on the warehouse floor.
>
> We would put a message out over the PA, but they just didn't listen.  It
> was a big warehouse, you couldn't find them all and if you killed of
> their client programs (all running on a central super-mini form HP) the
> some of buggers would log back on and by the time you had killed of the
> last one by hand the some would be logged back in.
>
> I did the whole job very fast on the CLI (there was no GUI for HPUX) in
> one line.  The other techies there, some with years of experience of the
> software, had no idea how to kill off the client programs quickly.
>
> "ps" lists the processes running on a *nix system.  On Linux the best
> arguments to use are "-elf" to get the full listing.  Best for human
> reading that is, but for this purpose "-ef" gives me just the info I need.
>
>      $ ps -ef
>
> You get a long list that includes information like the user that the
> process is being run by, time it was started, it's unique processes
> identity (pid) and the pid of its parent process, not to mention the
> process command itself.
>
> We only wanted to kill of one particular process name run by the same
> users. (All the pickers logged on using that same account.)  The best
> command for filtering text information is grep.
>
>     $ ps -ef | grep ^user | grep program
>
> I used two greps.  The first picks out all the command by the fixed user
> ("user" here).  It passes that filtered list to the second grep which
> just picks out those entries that are the command ("program").  But this
> list still isn't really useable yet.  We can do more!
>
> To kill a process you need to pass the pid to the "kill" command.  The
> pid is listed in the second column.  awk is a powerful scripting
> language in it's own right, here I use it to construct the commands to
> kill the programs I wanted:
>
>     $ ps -ef | grep ^user | grep program | awk '{print "kill " $2}'
>
> There are all the kill commands to kill off the program we wanted.  But
> re-typing them in would take an age.
>
> Now one could send those commands to a file make the file executable and
> then execute it but there is a much simpler way.  If you feed a set of
> commands into a CLI shell it will execute them!
>
>     $ ps -ef | grep ^user | grep program | awk '{print "kill " $2}' | sh
>
> There!  A one line script to find a set of processes run by the same
> user account and kill them.  I took me a couple of minutes to build the
> script up, bit by bit more or less as I did above on site live.
>
> Would anyone be interested in a talk like that?

Yes.
A talk along those lines would be very helpful so I shall look forward 
to it.

Thanks Steve, for thinking about this one and for your considered reply, 
it is very constructive and very helpful.



More information about the Sussex mailing list