NetBSD-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Scripting for /bin/ksh
I got the first script done. I think I can manage (?) now...
On Mon, Aug 2, 2021 at 1:12 PM Chavdar Ivanov <ci4ic4%gmail.com@localhost> wrote:
>
> On Mon, 2 Aug 2021 at 14:16, Todd Gruhn <tgruhn2%gmail.com@localhost> wrote:
> >
> > Thanks for the code Matt.
> > I will try this.
> > By 'execute' I mean generate
> > ${cmd}
> > then execute/do whatever ${cmd} turns out to be.
>
> Depending on the contents of cmd, you might have to use
>
> eval ${cmd}
>
> (if it requires further ksh parsing, e.g. wildcards)
>
> >
> >
> > On Mon, Aug 2, 2021 at 8:35 AM matthew sporleder <msporleder%gmail.com@localhost> wrote:
> > >
> > > On Mon, Aug 2, 2021 at 8:23 AM Todd Gruhn <tgruhn2%gmail.com@localhost> wrote:
> > > >
> > > > I am attempting to write some ksh-scripts that invoke "borg" .
> > > > How does one tell ksh to cat the 2 vars together and invoke the
> > > > resulting command?
> > > >
> > > > $foo <--> /umass1/BORG-REPOS
> > > > $FIRSThalf <--> borg-3.8 list
> > > > $cmd= $FIRSThalf . $foo #thats how it is coded in PERL
> > > >
> > > > execute $cmd
> > > >
> > > > I never learned much about /bin/ksh -- I jumped straight into PERL.
> > > > Anyone know of some good PDFs regarding this?
> > > >
> > > > Any help will be appreciated.
> > >
> > >
> > > foo="ls"
> > > bar="/tmp"
> > > cmd="${foo} ${bar}"
> > > ${cmd} #runs ls /tmp
> > > ---
> > > output=$(${foo} ${bar}) #captures the output
> > >
> > > not sure what "execute" is here
> > >
> > > Your perl code wouldn't work because you don't have spaces using the `.`
> > >
> > > working perl (looks just like the shell script):
> > > perl -e '$foo = "ls"; $bar = "/tmp"; $cmd = "${foo} ${bar}"; print qx#$cmd#;'
>
>
>
> --
> ----
Home |
Main Index |
Thread Index |
Old Index