From: Don Petrowski <dpetrowski@ci.collierville.tn.us>
To: Paul Kraus <pkraus@pelsupply.com>
Cc: linux-newbie@vger.kernel.org
Subject: Re: Bash Scripts
Date: 10 Oct 2002 16:13:20 -0500 [thread overview]
Message-ID: <1034284400.3222.7.camel@workwatcher> (raw)
In-Reply-To: <003301c2709c$7ac11b00$64fea8c0@pkrausxp>
1. the first value passed from the command line would be referenced as
$1 the second as $2
2. run command as part of an if statement. if the command execute
successfully the error result will be 0 and follow the then branch other
wise the else.
On Thu, 2002-10-10 at 15:34, Paul Kraus wrote:
> I have a script that mounts an samba shared drive, copies the contents
> if newer to the Linux box, and then umounts the share.
>
> Sample script
> ---
> mount -t smbfs -o username=x,password=y //machine/share /mnt/network
> cp --recursive --preserve --verbose --parents --update /mnt/network/*
> /backup/machine \
> > log1.txt 2>log2.txt
> umount /mnt/network
> ------------
> End script
>
> A couple of easy questions I can't seem to find answers to.
> 1. How can I pass in parameters from the command line to use as
> variables.
> myscript value1 value2
> 2. How can I have it dump a message to a log file if something fails and
> then cease running the script.
> if mount fail append to end of log1.txt "mounting failed",
> terminate script.
>
> I was under the impression that you could have a script terminate if a
> command failed by having && separate the commands but this just
> generates an error.
>
> Paul Kraus
> Network Administrator
> PEL Supply Company
> 216.267.5775 Voice
> 216-267-6176 Fax
> www.pelsupply.com
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
next prev parent reply other threads:[~2002-10-10 21:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-10 20:34 Bash Scripts Paul Kraus
2002-10-10 21:13 ` Don Petrowski [this message]
2002-10-10 21:16 ` Ray Olszewski
2002-10-10 21:33 ` Don Petrowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1034284400.3222.7.camel@workwatcher \
--to=dpetrowski@ci.collierville.tn.us \
--cc=linux-newbie@vger.kernel.org \
--cc=pkraus@pelsupply.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox