| ECS Home Automation and Security Archives |
| Subject: From: Date: | Re: [ecs] Linux progress Danny White Thu, 18 Sep 2003 19:36:36 -0500 |
The following is an example:
function docd
{
cd $1
echo "cd to $1"
}
If you put this is a file called tst.sh, and execute the command:
". tst.sh"
you can then type "docd .." and it will echo "cd to .." and will leave you in
the parent directory.
functions can be called within functions etc. to make commands of any
complexity.
ymos,
danny
On Thursday 18 September 2003 05:43 am, you wrote:
> Hi Danny,
> Could you give an example ?
> Thanks,
>
> At 09:42 PM 9/17/2003 -0500, you wrote:
> >The problem you are running into is that when you run a script in the
> > shell, it is run in a subshell. Any cd's, set var followed by export
> > etc. only effect the subshell and any subshells it might start. Once it
> > is finished, it exits back to the parent shell which is unchanged. One
> > solution to the problem is to use the "." to source in a script. This
> > causes the script to be run in the current shell instead of a subshell.
> > Another way of doing it is to write the commands you want to run as
> > functions in the script and source in (".") the definitions. After that,
> > the commands will work in the current shell.
> >
> >Hope that helped some.
> >
> >ymos,
> >danny
> >
> >On Wednesday 17 September 2003 07:26 am, you wrote:
> > > say what ? :-)
> > >
> > > At 10:15 PM 9/16/2003 -0700, you wrote:
> > > >Mark,
> > > >
> > > >Try this " . .sh"
> > > >
> > > >Rick Mortensen
> > > >www.can-be-scanned.com/HomeAutomation
> > > >----- Original Message -----
> > >
> > > From: "Mark Gilmore" <mark@markgilmore.net>
> > >
> > > >To: <ecs@netbloc.com>
> > > >Sent: Tuesday, September 16, 2003 18:02
> > > >Subject: [ecs] Linux progress
> > > >
> > > > > A re-install seems to have eliminated all my connection problems
> > > > > :-). I can now connect and transfer files in both directions.
> > > > > ECS is virtually compiled (a few lines yet to fix up).
> > > > > I will begin testing it tomorrow.
> > > > >
> > > > > I would still like to know how to run a .sh, such that the result
> > > > > would be *exactly* as if I typed the commands in the .sh.
> > > > > For example, I want to use .sh files to CD to other folders.
> > > > >
> > > > > Mark Gilmore
> > > > > http://OmnipotenceSoftware.com
> > > >
> > > >----------------------------------------------------------------------
> > > >---- -- ----
> > > >
> > > > > ---
> > > > > Outgoing mail is certified Virus Free.
> > > > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > > > Version: 6.0.512 / Virus Database: 309 - Release Date: 8/19/2003
> > > >
> > > >---
> > > >Incoming mail is certified Virus Free.
> > > >Checked by AVG anti-virus system (http://www.grisoft.com).
> > > >Version: 6.0.512 / Virus Database: 309 - Release Date: 8/19/2003
> > >
> > > Mark Gilmore
> > > http://OmnipotenceSoftware.com
> >
> >---
> >Incoming mail is certified Virus Free.
> >Checked by AVG anti-virus system (http://www.grisoft.com).
> >Version: 6.0.512 / Virus Database: 309 - Release Date: 8/19/2003
>
> Mark Gilmore
> http://OmnipotenceSoftware.com