1

I'm trying to find out if Ruby has en equivalent of php's fopen() method currently used like this:

$fd = fopen("php://stdin", "r");

would that be using ARGV variable?

Basically what I plan on doing is forward raw e-mail messages using the .procmailrc file which I already got working in a test php file, but the project requires the use of Ruby. Therefore I'm not 100% sure if using the ARGV variable would work or if somehow I need to capture the e-mail stream by some other means.

Any help would be greatly appreciated. Thanks :)

Charles
  • 50,943
  • 13
  • 104
  • 142
lagrz
  • 79
  • 5

2 Answers2

2

ARGV and the (standard) input stream are two different things. ARGV contains the parameters passed to an executable, like someapp a b c where a, b and are parameters. stdin is a file handle. You usually have three standard streams. stdin which is read-only, stdout and stderr which are write-only.

In Ruby you can use the predefined constants STDIN, STDOUT and STDERR to access the default streams. There are also the variables $stdin, $stdout, $stderr which are initialized with the same values as STDIN, STDOOUT and STERR but may be re-assigned other values.

VolkerK
  • 95,432
  • 20
  • 163
  • 226
0

You were probably referring to ARGF variable, have a look:

Best practices with STDIN in Ruby?

Community
  • 1
  • 1
Mladen Jablanović
  • 43,461
  • 10
  • 90
  • 113