a little script

Chris Aitken aitken-BwLjziHGQLusTnJN9+BGXg at public.gmane.org
Tue Jan 27 03:07:32 UTC 2004


Paul Mora wrote:

> 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.

Yes, sorry - I saved that email. I guess as soon as I was able to print via
CUPS, I put it in the back-burner. Then I saw this new wish (for an icon to
suspend hardware in linux to free it up for the W98 vm) as unconnected to any
emails I had kept on the printing issue. I'll take another look.

> Samba is the software that allows your
> Linux machine to be seen in a Windows Network Neighbourhood and
> participate in file and print sharing.

Yeah, I actually used it on redhat 6 to show some MS-linux interoperability
to a sceptical PC troubleshooting class of MS-heads. I actually got them to
see a Windows share in linux.

> 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.

OK, I'll have to think on this. I don't really want to go too far down the
path of MS-linux interoperability - I just need the W98 vm to run an app
(Pro Tools Free) that digidesign has not seen the wisdom in porting to linux.
I'd rather learn a little scripting to bring on linux like a dog in heat,
rather than holding hands with MS any more than I have to. But your
suggestion is intriguing...

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

Nice offer - I'll keep this email as hard copy in my refernce binder - I'll
probably need your help.

>
> > 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).

OK.

>
> 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

I type all that into vi? Are the #'s remarks or do they represent the command
prompt ($ on my rh 7.3 system)? This file in the example I would save as
myscript.sh and run it by typing myscript.sh or ./myscript.sh or $
!myscript.sh or some such?

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

Neat.

> 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.

They may still have programming basic course online at BLT.

>
> > 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.

Sounds like it.

:)

>
> Hope this helped a bit.

It did.

[...]

Chris

--
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