a little script

Paul Mora paulmora-bJEeYj9oJeDQT0dZR+AlfA at public.gmane.org
Tue Jan 27 02:35:03 UTC 2004


On Mon, 2004-01-26 at 20:51, Chris Aitken wrote:
> I want to write a little script, if that's the right word. Never done
> anything like that. Switching to VMware W98 vm means disabling cdrom,
> floppy, serial  amd parallel ports in linux first. I tried making a
> little panel applet containing the commands,
> 
> su; [password]; /sbin/service cups stop; /sbin/modprobe -r lp
> 
> to free up the parallel port so the W98 vm can use it.

I mentioned this to you in a previous post, but a much easier way to
print from both Linux and VMware to the same parallel attached printer
is to enable Samba under Linux.  Samba is the software that allows your
Linux machine to be seen in a Windows Network Neighbourhood and
participate in file and print sharing.  Depending on the distro, you may
only need to start it up, and it will automatically export all your
printers as Samba shares.  Then you should see them in the VMware
guest's Network Neighbourhood (ie. in Red Hat, all you need to do is
install the Samba RPMs, and start it up with "service smb start".)  In
VMware you configure them as you would any normal printer.

If you want more details, fire me an email and we can talk about it.

> I guess this is not the correct syntax, or panel icons cannot accept
> plain text passwords, or I am tryiing to do more than a panel icon can
> handle. I'm not looking to be coddled here (honestly), but if I want to
> write little things like this (and I doubt it will be the last) what
> should I be reading up on? Scripting, programming? Shell scripting?

A shell script is simply a file with a series of commands you want to
run.  Open up a text editor, type the commands you want to run (one per
line is a good way to start), and save it.  Then change the permissions
on the file to make it executable (chmod +x myscript.sh).

Here's a very simple example script to do what you want (I know, I'll
probably be flamed by the scripting experts out there):

#!/bin/bash
#
# Simple script to stop printing services and unload the parallel
# port module
service cups stop 
modprobe -r lp
exit 0

Of course, you could add all sorts of things like error checking, output
to the screen, etc.

Because it needs to be run as root, you may want to use a program like
"sudo"; it allows you to run specific commands/scripts as the root user
without having to actually su manually.  "man sudo" will get you all the
info you need on sudo.

To learn shell scripting, you can get any number of Bash shell
programming books, available from Oreilly and other publishers.  There's
also a real good shell programming book called "Advanced Bash Shell
Scripting" available at http://www.tldp.org/LDP/abs/html/.  You can also
get it in a downloadable PDF format.

Your other option is to take a course, but that may be costly depending
on who's offering the course and how long it is.

> Already I can see I'll be wanting to expand that to umount floppy, cdrom
> and God-knows-what-else.

Understanding the basics of shell scripting extremely useful.

Hope this helped a bit.

pm

-- 
Paul Mora <paulmora-bJEeYj9oJeDQT0dZR+AlfA at public.gmane.org>

--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list