public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* Shell input redirection question
@ 2017-09-21  6:11 Tiger Liu
  2017-09-21 11:51 ` Jim.Dailey
  0 siblings, 1 reply; 6+ messages in thread
From: Tiger Liu @ 2017-09-21  6:11 UTC (permalink / raw)
  To: edk2-devel@lists.01.org

Hi, experts:
I have a question about input redirection in Shell environment.

Take pci command as sample.
I wrote a txt file(file name is : inputsample.txt), its content is:
00 00 01 -i
00 00 02 –i

It means I just wanted to dump D0F1/D0F2’s config space.

Then, I use this command sequence in shell :
pci <a inputsample.txt

But it seems not recognize this input file’s content.

Why?

Thanks

best wishes,


保密声明:
本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容做任何未经授权的查阅、使用、复制或转发。
CONFIDENTIAL NOTE:
This email contains confidential or legally privileged information and is for the sole use of its intended recipient. Any unauthorized review, use, copying or forwarding of this email or the content of this email is strictly prohibited.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Shell input redirection question
  2017-09-21  6:11 Tiger Liu
@ 2017-09-21 11:51 ` Jim.Dailey
  2017-09-21 13:11   ` Carsey, Jaben
  0 siblings, 1 reply; 6+ messages in thread
From: Jim.Dailey @ 2017-09-21 11:51 UTC (permalink / raw)
  To: TigerLiu; +Cc: edk2-devel

The shell's pci command was not written to read from standard input. It
expects all its input on the command line.

I would say in general that if you execute a command and pass it no
parameters, and it then prompts you in some way for input, then that
command will likely accept input redirected from a file.

If you execute pci without any parameters, it simply lists all the
devices in the system and terminates, so it clearly is not prepared to
read from standard input (or a redirected file).

It is strictly up to whomever writes a program/command whether they do
so in a manner that allows it to accept input from standard input. For
example, I have written a grep utility for the shell that expects one or
more filenames to search to be on the command line; however, if there
are no filenames on the command line, the utility searches standard
input.

Regards,
Jim

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Tiger Liu
Sent: Thursday, September 21, 2017 1:11 AM
To: edk2-devel@lists.01.org
Subject: [edk2] Shell input redirection question

Hi, experts:
I have a question about input redirection in Shell environment.

Take pci command as sample.
I wrote a txt file(file name is : inputsample.txt), its content is:
00 00 01 -i
00 00 02 –i

It means I just wanted to dump D0F1/D0F2’s config space.

Then, I use this command sequence in shell :
pci <a inputsample.txt

But it seems not recognize this input file’s content.

Why?

Thanks

best wishes,


保密声明:
本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容做任何未经授权的查阅、使用、复制或转发。
CONFIDENTIAL NOTE:
This email contains confidential or legally privileged information and is for the sole use of its intended recipient. Any unauthorized review, use, copying or forwarding of this email or the content of this email is strictly prohibited.
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Shell input redirection question
  2017-09-21 11:51 ` Jim.Dailey
@ 2017-09-21 13:11   ` Carsey, Jaben
  2017-09-21 13:32     ` Jim.Dailey
  0 siblings, 1 reply; 6+ messages in thread
From: Carsey, Jaben @ 2017-09-21 13:11 UTC (permalink / raw)
  To: Jim.Dailey@dell.com, TigerLiu@zhaoxin.com; +Cc: edk2-devel@lists.01.org

If the requirement for PCI to display the information when there are no parameters present, I see no reason that it could not also use a file for input.  i.e. "pci" must act according to the spec, but "pci < inputfile" is not prohibited.  I think that as no code currently uses PCI with file input as long as current behavior still works it should be fine.

I would think that would be a great improvement for the PCI command.

-Jaben

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Jim.Dailey@dell.com
> Sent: Thursday, September 21, 2017 4:52 AM
> To: TigerLiu@zhaoxin.com
> Cc: edk2-devel@lists.01.org
> Subject: Re: [edk2] Shell input redirection question
> Importance: High
> 
> The shell's pci command was not written to read from standard input. It
> expects all its input on the command line.
> 
> I would say in general that if you execute a command and pass it no
> parameters, and it then prompts you in some way for input, then that
> command will likely accept input redirected from a file.
> 
> If you execute pci without any parameters, it simply lists all the
> devices in the system and terminates, so it clearly is not prepared to
> read from standard input (or a redirected file).
> 
> It is strictly up to whomever writes a program/command whether they do
> so in a manner that allows it to accept input from standard input. For
> example, I have written a grep utility for the shell that expects one or
> more filenames to search to be on the command line; however, if there
> are no filenames on the command line, the utility searches standard
> input.
> 
> Regards,
> Jim
> 
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Tiger Liu
> Sent: Thursday, September 21, 2017 1:11 AM
> To: edk2-devel@lists.01.org
> Subject: [edk2] Shell input redirection question
> 
> Hi, experts:
> I have a question about input redirection in Shell environment.
> 
> Take pci command as sample.
> I wrote a txt file(file name is : inputsample.txt), its content is:
> 00 00 01 -i
> 00 00 02 –i
> 
> It means I just wanted to dump D0F1/D0F2’s config space.
> 
> Then, I use this command sequence in shell :
> pci <a inputsample.txt
> 
> But it seems not recognize this input file’s content.
> 
> Why?
> 
> Thanks
> 
> best wishes,
> 
> 
> 保密声明:
> 本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件
> 或其内容做任何未经授权的查阅、使用、复制或转发。
> CONFIDENTIAL NOTE:
> This email contains confidential or legally privileged information and is for the
> sole use of its intended recipient. Any unauthorized review, use, copying or
> forwarding of this email or the content of this email is strictly prohibited.
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Shell input redirection question
  2017-09-21 13:11   ` Carsey, Jaben
@ 2017-09-21 13:32     ` Jim.Dailey
  2017-09-21 14:13       ` Carsey, Jaben
  0 siblings, 1 reply; 6+ messages in thread
From: Jim.Dailey @ 2017-09-21 13:32 UTC (permalink / raw)
  To: jaben.carsey; +Cc: edk2-devel, TigerLiu

I think the technicality here is that given "pci < inputfile", no
parameters are passed to the pci command, so it should, according to
the spec, display all the devices.

Another problem may be that in the "pci < inputfile" case, the pci
command has no way to know that its input is being redirected and that
it should behave differently than normal. I may be wrong about that
point; I know it is possible, but it might require some sort of generic
change or addition to the shell's behavior.

A different tack would be to add (in a future spec version) a command
line argument that simply indicated to pci that its input (commands)
are in some file (e.g. "pci -cmdfile inputfile"). Of course, if that
were to happen, the new spec should also specify the format of the
command file's content.

A simple way to do what Tiger was trying and that works right now is
to create a shell script instead of an input file:

    @echo -off
    pci 00 00 01 -i
    pci 00 00 02 -i

Regards,
Jim

-----Original Message-----
From: Carsey, Jaben [mailto:jaben.carsey@intel.com] 
Sent: Thursday, September 21, 2017 8:11 AM
To: Dailey, Jim <Jim_Dailey@Dell.com>; TigerLiu@zhaoxin.com
Cc: edk2-devel@lists.01.org
Subject: RE: [edk2] Shell input redirection question

If the requirement for PCI to display the information when there are no parameters present, I see no reason that it could not also use a file for input.  i.e. "pci" must act according to the spec, but "pci < inputfile" is not prohibited.  I think that as no code currently uses PCI with file input as long as current behavior still works it should be fine.

I would think that would be a great improvement for the PCI command.

-Jaben

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Jim.Dailey@dell.com
> Sent: Thursday, September 21, 2017 4:52 AM
> To: TigerLiu@zhaoxin.com
> Cc: edk2-devel@lists.01.org
> Subject: Re: [edk2] Shell input redirection question
> Importance: High
> 
> The shell's pci command was not written to read from standard input. It
> expects all its input on the command line.
> 
> I would say in general that if you execute a command and pass it no
> parameters, and it then prompts you in some way for input, then that
> command will likely accept input redirected from a file.
> 
> If you execute pci without any parameters, it simply lists all the
> devices in the system and terminates, so it clearly is not prepared to
> read from standard input (or a redirected file).
> 
> It is strictly up to whomever writes a program/command whether they do
> so in a manner that allows it to accept input from standard input. For
> example, I have written a grep utility for the shell that expects one or
> more filenames to search to be on the command line; however, if there
> are no filenames on the command line, the utility searches standard
> input.
> 
> Regards,
> Jim
> 
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Tiger Liu
> Sent: Thursday, September 21, 2017 1:11 AM
> To: edk2-devel@lists.01.org
> Subject: [edk2] Shell input redirection question
> 
> Hi, experts:
> I have a question about input redirection in Shell environment.
> 
> Take pci command as sample.
> I wrote a txt file(file name is : inputsample.txt), its content is:
> 00 00 01 -i
> 00 00 02 –i
> 
> It means I just wanted to dump D0F1/D0F2’s config space.
> 
> Then, I use this command sequence in shell :
> pci <a inputsample.txt
> 
> But it seems not recognize this input file’s content.
> 
> Why?
> 
> Thanks
> 
> best wishes,
> 
> 
> 保密声明:
> 本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件
> 或其内容做任何未经授权的查阅、使用、复制或转发。
> CONFIDENTIAL NOTE:
> This email contains confidential or legally privileged information and is for the
> sole use of its intended recipient. Any unauthorized review, use, copying or
> forwarding of this email or the content of this email is strictly prohibited.
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Shell input redirection question
  2017-09-21 13:32     ` Jim.Dailey
@ 2017-09-21 14:13       ` Carsey, Jaben
  0 siblings, 0 replies; 6+ messages in thread
From: Carsey, Jaben @ 2017-09-21 14:13 UTC (permalink / raw)
  To: Jim.Dailey@dell.com; +Cc: edk2-devel@lists.01.org, TigerLiu@zhaoxin.com

The SHELL_PARAMETERS_PROTOCOL used by the pci command lists both the command line and the StdIn for the command.  I think that you could check the StdIn for the file specified and then change the behavior.

If we really require a parameter to enable some sort of file input mode, the spec says that implementers can freely add -_<blah> parameters.  In the past these have even been moved to standard parameters in future versions of the spec (-_exit is an example that springs to mind for me).

I also agree that your sample NSH file is definitely the quickest way to get a solution in this case.

-Jaben

> -----Original Message-----
> From: Jim.Dailey@dell.com [mailto:Jim.Dailey@dell.com]
> Sent: Thursday, September 21, 2017 6:32 AM
> To: Carsey, Jaben <jaben.carsey@intel.com>
> Cc: edk2-devel@lists.01.org; TigerLiu@zhaoxin.com
> Subject: RE: [edk2] Shell input redirection question
> Importance: High
> 
> I think the technicality here is that given "pci < inputfile", no
> parameters are passed to the pci command, so it should, according to
> the spec, display all the devices.
> 
> Another problem may be that in the "pci < inputfile" case, the pci
> command has no way to know that its input is being redirected and that
> it should behave differently than normal. I may be wrong about that
> point; I know it is possible, but it might require some sort of generic
> change or addition to the shell's behavior.
> 
> A different tack would be to add (in a future spec version) a command
> line argument that simply indicated to pci that its input (commands)
> are in some file (e.g. "pci -cmdfile inputfile"). Of course, if that
> were to happen, the new spec should also specify the format of the
> command file's content.
> 
> A simple way to do what Tiger was trying and that works right now is
> to create a shell script instead of an input file:
> 
>     @echo -off
>     pci 00 00 01 -i
>     pci 00 00 02 -i
> 
> Regards,
> Jim
> 
> -----Original Message-----
> From: Carsey, Jaben [mailto:jaben.carsey@intel.com]
> Sent: Thursday, September 21, 2017 8:11 AM
> To: Dailey, Jim <Jim_Dailey@Dell.com>; TigerLiu@zhaoxin.com
> Cc: edk2-devel@lists.01.org
> Subject: RE: [edk2] Shell input redirection question
> 
> If the requirement for PCI to display the information when there are no
> parameters present, I see no reason that it could not also use a file for input.
> i.e. "pci" must act according to the spec, but "pci < inputfile" is not prohibited.
> I think that as no code currently uses PCI with file input as long as current
> behavior still works it should be fine.
> 
> I would think that would be a great improvement for the PCI command.
> 
> -Jaben
> 
> > -----Original Message-----
> > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> > Jim.Dailey@dell.com
> > Sent: Thursday, September 21, 2017 4:52 AM
> > To: TigerLiu@zhaoxin.com
> > Cc: edk2-devel@lists.01.org
> > Subject: Re: [edk2] Shell input redirection question
> > Importance: High
> >
> > The shell's pci command was not written to read from standard input. It
> > expects all its input on the command line.
> >
> > I would say in general that if you execute a command and pass it no
> > parameters, and it then prompts you in some way for input, then that
> > command will likely accept input redirected from a file.
> >
> > If you execute pci without any parameters, it simply lists all the
> > devices in the system and terminates, so it clearly is not prepared to
> > read from standard input (or a redirected file).
> >
> > It is strictly up to whomever writes a program/command whether they do
> > so in a manner that allows it to accept input from standard input. For
> > example, I have written a grep utility for the shell that expects one or
> > more filenames to search to be on the command line; however, if there
> > are no filenames on the command line, the utility searches standard
> > input.
> >
> > Regards,
> > Jim
> >
> > -----Original Message-----
> > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> > Tiger Liu
> > Sent: Thursday, September 21, 2017 1:11 AM
> > To: edk2-devel@lists.01.org
> > Subject: [edk2] Shell input redirection question
> >
> > Hi, experts:
> > I have a question about input redirection in Shell environment.
> >
> > Take pci command as sample.
> > I wrote a txt file(file name is : inputsample.txt), its content is:
> > 00 00 01 -i
> > 00 00 02 –i
> >
> > It means I just wanted to dump D0F1/D0F2’s config space.
> >
> > Then, I use this command sequence in shell :
> > pci <a inputsample.txt
> >
> > But it seems not recognize this input file’s content.
> >
> > Why?
> >
> > Thanks
> >
> > best wishes,
> >
> >
> > 保密声明:
> > 本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮
> 件
> > 或其内容做任何未经授权的查阅、使用、复制或转发。
> > CONFIDENTIAL NOTE:
> > This email contains confidential or legally privileged information and is for
> the
> > sole use of its intended recipient. Any unauthorized review, use, copying or
> > forwarding of this email or the content of this email is strictly prohibited.
> > _______________________________________________
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel
> > _______________________________________________
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Shell input redirection question
@ 2017-09-22  1:21 Tiger Liu
  0 siblings, 0 replies; 6+ messages in thread
From: Tiger Liu @ 2017-09-22  1:21 UTC (permalink / raw)
  To: Carsey, Jaben, Jim.Dailey@dell.com; +Cc: edk2-devel@lists.01.org

Hi, All:
Thanks for your suggestions.
Appreciate it.

Thanks

best wishes,
-----邮件原件-----
发件人: Carsey, Jaben [mailto:jaben.carsey@intel.com]
发送时间: 2017年9月21日 22:13
收件人: Jim.Dailey@dell.com
抄送: edk2-devel@lists.01.org; Tiger Liu
主题: RE: [edk2] Shell input redirection question

The SHELL_PARAMETERS_PROTOCOL used by the pci command lists both the command line and the StdIn for the command.  I think that you could check the StdIn for the file specified and then change the behavior.

If we really require a parameter to enable some sort of file input mode, the spec says that implementers can freely add -_<blah> parameters.  In the past these have even been moved to standard parameters in future versions of the spec (-_exit is an example that springs to mind for me).

I also agree that your sample NSH file is definitely the quickest way to get a solution in this case.

-Jaben

> -----Original Message-----
> From: Jim.Dailey@dell.com [mailto:Jim.Dailey@dell.com]
> Sent: Thursday, September 21, 2017 6:32 AM
> To: Carsey, Jaben <jaben.carsey@intel.com>
> Cc: edk2-devel@lists.01.org; TigerLiu@zhaoxin.com
> Subject: RE: [edk2] Shell input redirection question
> Importance: High
>
> I think the technicality here is that given "pci < inputfile", no
> parameters are passed to the pci command, so it should, according to
> the spec, display all the devices.
>
> Another problem may be that in the "pci < inputfile" case, the pci
> command has no way to know that its input is being redirected and that
> it should behave differently than normal. I may be wrong about that
> point; I know it is possible, but it might require some sort of
> generic change or addition to the shell's behavior.
>
> A different tack would be to add (in a future spec version) a command
> line argument that simply indicated to pci that its input (commands)
> are in some file (e.g. "pci -cmdfile inputfile"). Of course, if that
> were to happen, the new spec should also specify the format of the
> command file's content.
>
> A simple way to do what Tiger was trying and that works right now is
> to create a shell script instead of an input file:
>
>     @echo -off
>     pci 00 00 01 -i
>     pci 00 00 02 -i
>
> Regards,
> Jim
>
> -----Original Message-----
> From: Carsey, Jaben [mailto:jaben.carsey@intel.com]
> Sent: Thursday, September 21, 2017 8:11 AM
> To: Dailey, Jim <Jim_Dailey@Dell.com>; TigerLiu@zhaoxin.com
> Cc: edk2-devel@lists.01.org
> Subject: RE: [edk2] Shell input redirection question
>
> If the requirement for PCI to display the information when there are
> no parameters present, I see no reason that it could not also use a file for input.
> i.e. "pci" must act according to the spec, but "pci < inputfile" is not prohibited.
> I think that as no code currently uses PCI with file input as long as
> current behavior still works it should be fine.
>
> I would think that would be a great improvement for the PCI command.
>
> -Jaben
>
> > -----Original Message-----
> > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf
> > Of Jim.Dailey@dell.com
> > Sent: Thursday, September 21, 2017 4:52 AM
> > To: TigerLiu@zhaoxin.com
> > Cc: edk2-devel@lists.01.org
> > Subject: Re: [edk2] Shell input redirection question
> > Importance: High
> >
> > The shell's pci command was not written to read from standard input.
> > It expects all its input on the command line.
> >
> > I would say in general that if you execute a command and pass it no
> > parameters, and it then prompts you in some way for input, then that
> > command will likely accept input redirected from a file.
> >
> > If you execute pci without any parameters, it simply lists all the
> > devices in the system and terminates, so it clearly is not prepared
> > to read from standard input (or a redirected file).
> >
> > It is strictly up to whomever writes a program/command whether they
> > do so in a manner that allows it to accept input from standard
> > input. For example, I have written a grep utility for the shell that
> > expects one or more filenames to search to be on the command line;
> > however, if there are no filenames on the command line, the utility
> > searches standard input.
> >
> > Regards,
> > Jim
> >
> > -----Original Message-----
> > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf
> > Of Tiger Liu
> > Sent: Thursday, September 21, 2017 1:11 AM
> > To: edk2-devel@lists.01.org
> > Subject: [edk2] Shell input redirection question
> >
> > Hi, experts:
> > I have a question about input redirection in Shell environment.
> >
> > Take pci command as sample.
> > I wrote a txt file(file name is : inputsample.txt), its content is:
> > 00 00 01 -i
> > 00 00 02 –i
> >
> > It means I just wanted to dump D0F1/D0F2’s config space.
> >
> > Then, I use this command sequence in shell :
> > pci <a inputsample.txt
> >
> > But it seems not recognize this input file’s content.
> >
> > Why?
> >
> > Thanks
> >
> > best wishes,
> >
> >
> > 保密声明:
> > 本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮
> 件
> > 或其内容做任何未经授权的查阅、使用、复制或转发。
> > CONFIDENTIAL NOTE:
> > This email contains confidential or legally privileged information
> > and is for
> the
> > sole use of its intended recipient. Any unauthorized review, use,
> > copying or forwarding of this email or the content of this email is strictly prohibited.
> > _______________________________________________
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel
> > _______________________________________________
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel


保密声明:
本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容做任何未经授权的查阅、使用、复制或转发。
CONFIDENTIAL NOTE:
This email contains confidential or legally privileged information and is for the sole use of its intended recipient. Any unauthorized review, use, copying or forwarding of this email or the content of this email is strictly prohibited.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-09-22  1:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-22  1:21 Shell input redirection question Tiger Liu
  -- strict thread matches above, loose matches on Subject: below --
2017-09-21  6:11 Tiger Liu
2017-09-21 11:51 ` Jim.Dailey
2017-09-21 13:11   ` Carsey, Jaben
2017-09-21 13:32     ` Jim.Dailey
2017-09-21 14:13       ` Carsey, Jaben

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox