IO redirection

classic Classic list List threaded Threaded
32 messages Options
12
Reply | Threaded
Open this post in threaded view
|

IO redirection

Samba - linux mailing list
Perhaps it's the fish syntax. But all I could do was send output to a
file. I tried to execute input from a file--to no avail.

{

     To read standard input from a file, write <SOURCE_FILE
     To write standard output to a file, write >DESTINATION
     To write standard error to a file, write ^DESTINATION
     To append standard output to a file, write >>DESTINATION_FILE
     To append standard error to a file, write ^^DESTINATION_FILE
     To not overwrite ("clobber") an existing file, write
'>?DESTINATION' or '^?DESTINATION'

}

http://fishshell.com/docs/current/index.html
--
www.netspeed.com.au/bryan/

--
linux mailing list
[hidden email]
https://lists.samba.org/mailman/listinfo/linux
Reply | Threaded
Open this post in threaded view
|

Re: IO redirection

Samba - linux mailing list
On 16/09/17 23:15, Bryan Kilgallin (iiNet) via linux wrote:

> Perhaps it's the fish syntax. But all I could do was send output to a file. I tried to execute input from a file--to no avail.
>
> {
>
>      To read standard input from a file, write <SOURCE_FILE
>      To write standard output to a file, write >DESTINATION
>      To write standard error to a file, write ^DESTINATION
>      To append standard output to a file, write >>DESTINATION_FILE
>      To append standard error to a file, write ^^DESTINATION_FILE
>      To not overwrite ("clobber") an existing file, write '>?DESTINATION' or '^?DESTINATION'
>
> }
>
> http://fishshell.com/docs/current/index.html

Good morning  Bryan,

What command did you run to try to "execute input" and how did it fail?

For example, this command:
        sort <infile >outfile
should "read standard input", sort it, then "write standard output". does this work for you?

--
Eyal Lebedinsky ([hidden email])

--
linux mailing list
[hidden email]
https://lists.samba.org/mailman/listinfo/linux
Reply | Threaded
Open this post in threaded view
|

Re: IO redirection

Samba - linux mailing list
OK Eyal:

> What command did you run to try to "execute input" and how did it fail?

In fish, the following is a valid command.
{
echo Testing.
}

So I put that command into a "Test.txt" text file.

And in a terminal window, I entered the following.
{
exec <Test.txt
}

Resulting in the following screen output.
{
        exec -- execute command in current process

    Synopsis
        exec COMMAND [OPTIONS...]

    Description
        exec replaces the currently running shell with a new command. On
        successful completion, exec never returns. exec cannot be used
inside
        a pipeline.

    Example
        exec emacs starts up the emacs text editor, and exits fish. When
        emacs exits, the session will terminate.


}

What is the appropriate way to take instructions from a file, and do them?

> For example, this command:
>      sort <infile >outfile
> should "read standard input", sort it, then "write standard output".
> does this work for you?

Yes, that worked fine!
--
www.netspeed.com.au/bryan/

--
linux mailing list
[hidden email]
https://lists.samba.org/mailman/listinfo/linux
Reply | Threaded
Open this post in threaded view
|

Re: IO redirection

Samba - linux mailing list
> In fish, the following is a valid command.
> {
> echo Testing.
> }
>
> So I put that command into a "Test.txt" text file.

> What is the appropriate way to take instructions from a file, and do them?

I report success with the following.
{
eval (cat Test.txt)
}

This put the following on the screen.
{
Testing.
}
--
www.netspeed.com.au/bryan/

--
linux mailing list
[hidden email]
https://lists.samba.org/mailman/listinfo/linux
Reply | Threaded
Open this post in threaded view
|

Re: IO redirection

Samba - linux mailing list
In reply to this post by Samba - linux mailing list
Why not just:

fish Test.txt

or

. Test.txt

or

exec Test.txt
But that is probably not what you want to do.

> On 2017/Sep/17, at 10:06 PM, Bryan Kilgallin (iiNet) via linux <[hidden email]> wrote:
>
> OK Eyal:
>
>> What command did you run to try to "execute input" and how did it fail?
>
> In fish, the following is a valid command.
> {
> echo Testing.
> }
>
> So I put that command into a "Test.txt" text file.
>
> And in a terminal window, I entered the following.
> {
> exec <Test.txt
> }
>
> Resulting in the following screen output.
> {
>       exec -- execute command in current process
>
>   Synopsis
>       exec COMMAND [OPTIONS...]
>
>   Description
>       exec replaces the currently running shell with a new command. On
>       successful completion, exec never returns. exec cannot be used inside
>       a pipeline.
>
>   Example
>       exec emacs starts up the emacs text editor, and exits fish. When
>       emacs exits, the session will terminate.
>
>
> }
>
> What is the appropriate way to take instructions from a file, and do them?
>
>> For example, this command:
>>     sort <infile >outfile
>> should "read standard input", sort it, then "write standard output". does this work for you?
>
> Yes, that worked fine!
> --
> www.netspeed.com.au/bryan/
>
> --
> linux mailing list
> [hidden email]
> https://lists.samba.org/mailman/listinfo/linux

--
Kim Holburn
IT Network & Security Consultant
T: +61 2 61402408  M: +61 404072753
mailto:[hidden email]  aim://kimholburn
skype://kholburn - PGP Public Key on request




--
linux mailing list
[hidden email]
https://lists.samba.org/mailman/listinfo/linux
Reply | Threaded
Open this post in threaded view
|

Re: IO redirection

Samba - linux mailing list
Thanks for your interest, Kim:

> fish Test.txt

That actually worked! The desired result appeared beneath a Buddhist
saying. Displayed by the following package.

display-dhammapada

> . Test.txt

WTF? That worked too! But I can't find documentation explaining the use
of `.' as a command. Please refer me to such an explanatory page.

> exec Test.txt

That yielded the following error.
{
Test.txt: command not found
fish: exec Test.txt
            ^
}

> But that is probably not what you want to do.

I had been reading through the fish shell documentation. Trying to get
my head around the concepts. And also learning the syntax.
{
Most programs use three input/output (IO) streams, each represented by a
number called a file descriptor (FD). These are:

     Standard input, FD 0, for reading, defaults to reading from the
keyboard.
     Standard output, FD 1, for writing, defaults to writing to the screen.
     Standard error, FD 2, for writing errors and warnings, defaults to
writing to the screen.

The reason for providing for two output file descriptors is to allow
separation of errors and warnings from regular program output.

Any file descriptor can be directed to a different output than its
default through a simple mechanism called a redirection.

An example of a file redirection is echo hello > output.txt, which
directs the output of the echo command to the file output.txt.

     To read standard input from a file, write <SOURCE_FILE
     To write standard output to a file, write >DESTINATION
     To write standard error to a file, write ^DESTINATION
     To append standard output to a file, write >>DESTINATION_FILE
     To append standard error to a file, write ^^DESTINATION_FILE
     To not overwrite ("clobber") an existing file, write
'>?DESTINATION' or '^?DESTINATION'
}
http://fishshell.com/docs/current/index.html
--
www.netspeed.com.au/bryan/

--
linux mailing list
[hidden email]
https://lists.samba.org/mailman/listinfo/linux
Reply | Threaded
Open this post in threaded view
|

Re: IO redirection

Samba - linux mailing list
I found it!

>> . Test.txt
>
> WTF? That worked too! But I can't find documentation explaining the use
> of `.' as a command. Please refer me to such an explanatory page.

"source evaluates the commands of the specified file in the current
shell. This is different from starting a new process to perform the
commands (i.e. fish < FILENAME) since the commands will be evaluated by
the current shell, which means that changes in shell variables will
affect the current shell. If additional arguments are specified after
the file name, they will be inserted into the $argv variable. The $argv
variable will not include the name of the sourced file.

If no file is specified, or if the file name '-' is used, stdin will be
read.

The return status of source is the return status of the last job to
execute. If something goes wrong while opening or reading the file,
source exits with a non-zero status.

. (a single period) is an alias for the source command. The use of . is
deprecated in favour of source, and . will be removed in a future
version of fish."

https://fishshell.com/docs/current/commands.html#source
--
www.netspeed.com.au/bryan/

--
linux mailing list
[hidden email]
https://lists.samba.org/mailman/listinfo/linux
Reply | Threaded
Open this post in threaded view
|

Re: IO redirection

Samba - linux mailing list
In reply to this post by Samba - linux mailing list

> On 2017/Sep/18, at 12:11 AM, Bryan Kilgallin (iiNet) <[hidden email]> wrote:
>
>> exec Test.txt
>
> That yielded the following error.
> {
> Test.txt: command not found
> fish: exec Test.txt
>           ^
> }

for exec to work, Test.txt has to be executable and must be full path or in the path.

chmod 755 ./Test.txt

exec ./Test.txt

exec is always the last command executed in a script.  It doesn't return to the script.

--
Kim Holburn
IT Network & Security Consultant
T: +61 2 61402408  M: +61 404072753
mailto:[hidden email]  aim://kimholburn
skype://kholburn - PGP Public Key on request




--
linux mailing list
[hidden email]
https://lists.samba.org/mailman/listinfo/linux
Reply | Threaded
Open this post in threaded view
|

IO redirection

Samba - linux mailing list
Anything planned for this month?
--
linux mailing list
[hidden email]
https://lists.samba.org/mailman/listinfo/linux
Reply | Threaded
Open this post in threaded view
|

Re: Upcoming talk?

Samba - linux mailing list
On 18/09/17 17:03, George at Clug via linux wrote:
> Anything planned for this month?

I'm happy to give a talk about an Open Source project I'm working on at Red
Hat called Insights.

Insights is basically a way of automating 'situation' detection on Linux
computers.  'Situation' here is fairly broad - it can be anything from 'you
have a package with a known vulnerability listening on an open port' to 'you
have this hardware, which is incompatible with this setting in the software
you're running' to 'it looks like you can get more performance out of your
database if you set this setting here'.  The main repository:

https://github.com/RedHatInsights/insights-core

is open source and my current work is on getting a 'demo' set of rules open
sourced (mainly for lack of ideas rather than will).

This would be a more technical talk, looking at how you write rules in Python
for Insights, but I'm happy to spend a lot of time in Q&A covering what
Insights is, what it isn't, how it can help and how it isn't going to put
technical support people out of a job :-)

Is that interesting to anyone?

Hope this helps,

Paul

--
linux mailing list
[hidden email]
https://lists.samba.org/mailman/listinfo/linux
Reply | Threaded
Open this post in threaded view
|

Re: Upcoming talk?

Samba - linux mailing list
I'd be rather interested...

On 18 September 2017 at 22:59, Paul Wayper via linux <[hidden email]>
wrote:

> On 18/09/17 17:03, George at Clug via linux wrote:
> > Anything planned for this month?
>
> I'm happy to give a talk about an Open Source project I'm working on at Red
> Hat called Insights.
>
> Insights is basically a way of automating 'situation' detection on Linux
> computers.  'Situation' here is fairly broad - it can be anything from 'you
> have a package with a known vulnerability listening on an open port' to
> 'you
> have this hardware, which is incompatible with this setting in the software
> you're running' to 'it looks like you can get more performance out of your
> database if you set this setting here'.  The main repository:
>
> https://github.com/RedHatInsights/insights-core
>
> is open source and my current work is on getting a 'demo' set of rules open
> sourced (mainly for lack of ideas rather than will).
>
> This would be a more technical talk, looking at how you write rules in
> Python
> for Insights, but I'm happy to spend a lot of time in Q&A covering what
> Insights is, what it isn't, how it can help and how it isn't going to put
> technical support people out of a job :-)
>
> Is that interesting to anyone?
>
> Hope this helps,
>
> Paul
>
> --
> linux mailing list
> [hidden email]
> https://lists.samba.org/mailman/listinfo/linux
>



--

  "I and the public know
  what all schoolchildren learn
  Those to whom evil is done
  Do evil in return" W.H. Auden, "September 1, 1939"
--
linux mailing list
[hidden email]
https://lists.samba.org/mailman/listinfo/linux
Reply | Threaded
Open this post in threaded view
|

Re: Upcoming talk?

Samba - linux mailing list
In reply to this post by Samba - linux mailing list
Sounds interesting.

Love the project name - guaranteed to get lost in business waffle in any
web search.

On Mon, 2017-09-18 at 22:59 +1000, Paul Wayper via linux wrote:

> On 18/09/17 17:03, George at Clug via linux wrote:
> > Anything planned for this month?
>
> I'm happy to give a talk about an Open Source project I'm working on at Red
> Hat called Insights.
>
> Insights is basically a way of automating 'situation' detection on Linux
> computers.  'Situation' here is fairly broad - it can be anything from 'you
> have a package with a known vulnerability listening on an open port' to 'you
> have this hardware, which is incompatible with this setting in the software
> you're running' to 'it looks like you can get more performance out of your
> database if you set this setting here'.  The main repository:
>
> https://github.com/RedHatInsights/insights-core
>
> is open source and my current work is on getting a 'demo' set of rules open
> sourced (mainly for lack of ideas rather than will).
>
> This would be a more technical talk, looking at how you write rules in Python
> for Insights, but I'm happy to spend a lot of time in Q&A covering what
> Insights is, what it isn't, how it can help and how it isn't going to put
> technical support people out of a job :-)
>
> Is that interesting to anyone?
>
> Hope this helps,
>
> Paul
>


--
linux mailing list
[hidden email]
https://lists.samba.org/mailman/listinfo/linux
Reply | Threaded
Open this post in threaded view
|

Re: Upcoming talk?

Samba - linux mailing list
In reply to this post by Samba - linux mailing list
On 18/09/2017 10:59 pm, Paul Wayper via linux wrote:

> On 18/09/17 17:03, George at Clug via linux wrote:
>> Anything planned for this month?
>
> I'm happy to give a talk about an Open Source project I'm working on at Red
> Hat called Insights.
>
> Insights is basically a way of automating 'situation' detection on Linux
> computers.  'Situation' here is fairly broad - it can be anything from 'you
> have a package with a known vulnerability listening on an open port' to 'you
> have this hardware, which is incompatible with this setting in the software
> you're running' to 'it looks like you can get more performance out of your
> database if you set this setting here'.  The main repository:
>
> https://github.com/RedHatInsights/insights-core
>
> is open source and my current work is on getting a 'demo' set of rules open
> sourced (mainly for lack of ideas rather than will).
>
> This would be a more technical talk, looking at how you write rules in Python
> for Insights, but I'm happy to spend a lot of time in Q&A covering what
> Insights is, what it isn't, how it can help and how it isn't going to put
> technical support people out of a job :-)
>
> Is that interesting to anyone?
>
> Hope this helps,
>
> Paul
>

Hi Paul,

We kind of agreed, back in June, to go bi-monthly, with Steve Walsh
giving his git talk last month, and the "privacy-fest" talks on in
October.

If you are sure you will be ready to go next week and if people are
keen to come and find out about Insights, then I am happy to come in
and open up etc.

Otherwise we can leave it to a future meeting?

cheers,

Bob Edwards.

--
linux mailing list
[hidden email]
https://lists.samba.org/mailman/listinfo/linux
Reply | Threaded
Open this post in threaded view
|

Re: Upcoming talk?

Samba - linux mailing list
In reply to this post by Samba - linux mailing list
Thanks, Paul:

> I'm happy to give a talk about an Open Source project I'm working on at Red
> Hat called Insights.
>
> Insights is basically a way of automating 'situation' detection on Linux
> computers.  'Situation' here is fairly broad - it can be anything from 'you
> have a package with a known vulnerability listening on an open port' to 'you
> have this hardware, which is incompatible with this setting in the software
> you're running' to 'it looks like you can get more performance out of your
> database if you set this setting here'.  The main repository:
>
> https://github.com/RedHatInsights/insights-core
>
> is open source and my current work is on getting a 'demo' set of rules open
> sourced (mainly for lack of ideas rather than will).
>
> This would be a more technical talk, looking at how you write rules in Python
> for Insights, but I'm happy to spend a lot of time in Q&A covering what
> Insights is, what it isn't, how it can help and how it isn't going to put
> technical support people out of a job :-)
>
> Is that interesting to anyone?

I think that anything is better than nothing!
--
www.netspeed.com.au/bryan/

--
linux mailing list
[hidden email]
https://lists.samba.org/mailman/listinfo/linux
Reply | Threaded
Open this post in threaded view
|

Re: Upcoming talk?

Samba - linux mailing list
In reply to this post by Samba - linux mailing list
Hey Bob:

> We kind of agreed, back in June, to go bi-monthly, with Steve Walsh
> giving his git talk last month, and the "privacy-fest" talks on in
> October.
>
> If you are sure you will be ready to go next week and if people are
> keen to come and find out about Insights, then I am happy to come in
> and open up etc.
>
> Otherwise we can leave it to a future meeting?

This seems ambivalent.

Paul will present.
Stephen, Brenton and I will watch!
--
www.netspeed.com.au/bryan/

--
linux mailing list
[hidden email]
https://lists.samba.org/mailman/listinfo/linux
Reply | Threaded
Open this post in threaded view
|

Re: Upcoming talk?

Samba - linux mailing list
In reply to this post by Samba - linux mailing list
On 19/09/17 09:56, Robert Edwards via linux wrote:

> Hi Paul,
>
> We kind of agreed, back in June, to go bi-monthly, with Steve Walsh
> giving his git talk last month, and the "privacy-fest" talks on in
> October.
>
> If you are sure you will be ready to go next week and if people are
> keen to come and find out about Insights, then I am happy to come in
> and open up etc.
>
> Otherwise we can leave it to a future meeting?

I really don't mind - I'm happy to fit in with the schedule and wait until
December.  If nothing else that should give me more of a chance to have the
demo rule set available.  If you were open to opening up the room on the 28th
of September, I'm happy to do the talk then too.  Whatever suits the Steves
and yourself.

Hope this helps,

Paul

--
linux mailing list
[hidden email]
https://lists.samba.org/mailman/listinfo/linux
Reply | Threaded
Open this post in threaded view
|

Re: Upcoming talk?

Samba - linux mailing list
I inadvertently sent this reply to just Paul. Resending it to the list.

The tail end of the talk notice for last month
(https://lists.samba.org/archive/linux/2017-August/036284.html) has

'=================================================
September Meeting - 28th September 2017 (Fourth Thursday of the month)

BeerSIG and Pizza night! No formal meeting, people are welcome to come
along
for either a beer at the Wig and Pen, or Pizza afterwards at GUILD.
================================================='

If Paul wants to give a talk in place of a social  gathering, and Bob is
available to open N101,  then it's easy enough to cancel the booking at
guild and have a regular technical meeting in its place.

On 19/09/17 22:10, Paul Wayper via linux wrote:

> On 19/09/17 09:56, Robert Edwards via linux wrote:
>> Hi Paul,
>>
>> We kind of agreed, back in June, to go bi-monthly, with Steve Walsh
>> giving his git talk last month, and the "privacy-fest" talks on in
>> October.
>>
>> If you are sure you will be ready to go next week and if people are
>> keen to come and find out about Insights, then I am happy to come in
>> and open up etc.
>>
>> Otherwise we can leave it to a future meeting?
> I really don't mind - I'm happy to fit in with the schedule and wait until
> December.  If nothing else that should give me more of a chance to have the
> demo rule set available.  If you were open to opening up the room on the 28th
> of September, I'm happy to do the talk then too.  Whatever suits the Steves
> and yourself.
>
> Hope this helps,
>
> Paul
>

--
linux mailing list
[hidden email]
https://lists.samba.org/mailman/listinfo/linux
Reply | Threaded
Open this post in threaded view
|

Re: Upcoming talk?

Samba - linux mailing list
In reply to this post by Samba - linux mailing list
1) A warning for others, I am expecting this session to get very
technical, would this be true Paul? (otherwise I will be a bit
disappointed).

2)  I don't mind waiting until later, but will later be November?

George


On 18/09/17 22:59, Paul Wayper via linux wrote:

> On 18/09/17 17:03, George at Clug via linux wrote:
>> Anything planned for this month?
> I'm happy to give a talk about an Open Source project I'm working on at Red
> Hat called Insights.
>
> Insights is basically a way of automating 'situation' detection on Linux
> computers.  'Situation' here is fairly broad - it can be anything from 'you
> have a package with a known vulnerability listening on an open port' to 'you
> have this hardware, which is incompatible with this setting in the software
> you're running' to 'it looks like you can get more performance out of your
> database if you set this setting here'.  The main repository:
>
> https://github.com/RedHatInsights/insights-core
>
> is open source and my current work is on getting a 'demo' set of rules open
> sourced (mainly for lack of ideas rather than will).
>
> This would be a more technical talk, looking at how you write rules in Python
> for Insights, but I'm happy to spend a lot of time in Q&A covering what
> Insights is, what it isn't, how it can help and how it isn't going to put
> technical support people out of a job :-)
>
> Is that interesting to anyone?
>
> Hope this helps,
>
> Paul
>


--
linux mailing list
[hidden email]
https://lists.samba.org/mailman/listinfo/linux
Reply | Threaded
Open this post in threaded view
|

Re: Upcoming talk?

Samba - linux mailing list
On 20/09/17 20:39, CLUG via linux wrote:
> 1) A warning for others, I am expecting this session to get very technical,
> would this be true Paul? (otherwise I will be a bit disappointed).

That's certainly my aim.  This is mainly going to be looking at, and
encouraging people to write, Python code.  It will help if you're familiar
with things like decorators, list comprehensions, yielding and generators, and
Python test frameworks, as I don't intend to explain how those work to any
great degree.

> 2)  I don't mind waiting until later, but will later be November?

Whenever suits Bob and the Steves.

Hope this helps,

Paul


--
linux mailing list
[hidden email]
https://lists.samba.org/mailman/listinfo/linux
Reply | Threaded
Open this post in threaded view
|

Re: Upcoming talk?

Samba - linux mailing list
On 21/09/17 17:34, Paul Wayper via linux wrote:
> Whenever suits Bob and the Steves.
Steve Hanley has a lot of work and other travel, so I'd taken it over
for a few months, working with Bob to put together a schedule of talks.
Rough schedule planned out was;

September 28th - originally planned as a 'bye' month, we had decided to
make this a social-ish night, and combine BeerSIG with some Pizza, and
just skip the meeting in the middle.

October 26th - Open Source Privacy-alooza - Bob

November 23rd - BBR Congestion control - Geoff Huston (APNIC)

December 28th - Christmas CLUG-at-a-PUB

January 25th - Skip due to LCA

February 22nd - LCA wrapup

it's far enough out that I can bump Geoff to next year and Paul can give
his talk in November, or I can cancel  the table at Guild and Paul can
give his talk next week.


--
linux mailing list
[hidden email]
https://lists.samba.org/mailman/listinfo/linux

signature.asc (836 bytes) Download Attachment
12