LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-26-2001, 10:29 PM   #1
Gene Snodgrass
LQ Newbie
 
Registered: Dec 2001
Location: Panama City Fl
Posts: 2

Rep: Reputation: 0
Scripting


Well here goes. I can spell Linux most ofthe time.. I have tried to write a script that would check for the /mnt/floppy directory.

I have tried quite a number of ways to write the "If"

something like if /mnt/floppy then .... or if "/mnt/floppy"
just get error messages from bash.

Also this fails also
#!/bin/bash
a=3
exit 0

Bash reports no command 3.

Have looked in many script files and see a great many assignments such as a=3 and then $a becomes a pointer.

I am using the latest Mandrake 8.2 I think..

Thanks Gene
 
Old 12-27-2001, 03:13 AM   #2
bluecadet
Member
 
Registered: Oct 2001
Distribution: MD81 RH71
Posts: 555

Rep: Reputation: 30
you need to read up a bit more on scripting. the IF structure is differnt in script than c etc... you have to use the test program to use an if properly

if [ -d /mnt/floppy ]

is probably what you want to do. the [ ] is the same as the test command:

if test -d /mnt/floppy

will return true if /mnt/floppy is a directory. I don't see what that will accomplish tho, as /mnt/floppy will always exist wether the floppy drive is mounted or not.

i'd recommend a general basic linux script book., they come in so useful

as for a=3, i'd assume you have rogue spaces in it. a= 3?
 
Old 12-27-2001, 05:43 PM   #3
Gene Snodgrass
LQ Newbie
 
Registered: Dec 2001
Location: Panama City Fl
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks for your kind help... looking for a file was just a test thing not unlike the a=3. I kinda feel that if I can't master basic script writing then I might be in great trouble trying to get a server on line.

Yes I will go for a good script book this week-end.

I have so many questions that it is hard to find a good place to start.

This is the script I wound up with after parsing things that did work.

#!/bin/bash
a=3
exit 0

The bash returne unknown command 3

The other major hurdle is automount! Or do I really need this feature. I am assuming I can write a script that I can run each time I bring the machine up that would mount the floppy and cd.

I have also read that if I wanted I could place working scripts in the /bin/ folder???? that would run each time the machine booted.

Any way most kind of you to assist this old man with you help.

Gene
 
Old 12-30-2001, 12:18 AM   #4
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
The bash script that assignes 3 to a should work. Try the command:
Code:
sh -x test.sh
Where test.sh is the name of your simple bash script. Post the output.

I never use automount.

Scripts that execute on boot should be started from the /etc/rc.d directory.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
new to scripting mifan Linux - Newbie 2 08-17-2005 12:10 PM
another help with scripting?! ice99 Programming 2 08-09-2005 08:56 AM
Need help scripting Tamara Programming 7 06-06-2005 02:06 AM
Scripting Help Please Jazinator Linux - Newbie 7 10-17-2004 06:35 PM
scripting bforest Linux - Newbie 4 05-11-2004 02:45 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration