Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2001-03

Read STIN on FreeBSD

14 messages · 8 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Neilson Henriques

Hi fellows ...

I'm a newbie using FPC so I asking for how can I read stdin. My FPC is 1.0.4 running under FreeBSD.

Thanks in advance.

Neilson

Reply by email

Jonas
Neilson Henriques wrote
I'm a newbie using FPC so I asking for how can I read stdin. My FPC is 1.0.4 running under FreeBSD.
var
  stdin: text;
  s: string;
begin
  assign(stdin,'');
  reset(stdin);
  readln(stdin,s);
end.

You can normally even simply use

var
  s: string;
begin
  readln(s);
end.

The default input is stdin.

Jnas

Reply by email

Noah silva
to Neilson Henriques: Hi fellows ... I'm a newbie using FPC so I asking for how can I read stdin. My FPC is…

Perhaps I misunderstand the question,

but couldn't you use Readln, read, or keypressed/readkey? (if you use the CRT unit). Under most systems (and Pascals), stdin is assigned to be the default for readln (and likewise stdout for writeln). So, to read in a string from the standard input, you could use:

var
 st:string;
begin
 readln(st);
end;

If you were looking for a charicter by charicter basis, you could use readkey. If you need more examples, let me know.

thanks,
noah silva

Neilson Henriques wrote 15 lines
Hi fellows ... I'm a newbie using FPC so I asking for how can I read stdin. My FPC is 1.0.4 running under FreeBSD. Thanks in advance. Neilson _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Jonas
Noah silva wrote
If you were looking for a charicter by charicter basis, you could use readkey. If you need more examples, let me know.

Note that readkey doesn't work with stdin, but with the keyboard (even if stdin is redirected from a file or so).

Jonas

Reply by email

Marco van de Voort
to Noah silva: Perhaps I misunderstand the question, but couldn't you use Readln, read, or…
Show quoted text 16 lines
Perhaps I misunderstand the question, but couldn't you use Readln, read, or keypressed/readkey? (if you use the CRT unit). Under most systems (and Pascals), stdin is assigned to be the default for readln (and likewise stdout for writeln). So, to read in a string from the standard input, you could use: var st:string; begin readln(st); end; If you were looking for a charicter by charicter basis, you could use readkey. If you need more examples, let me know.

It is possible to use readkey under FreeBSD, but from the ncrt unit, not the CRT unit. The Linux Crt unit is very Linux specific, and was not portable to FreeBSD.

Reply by email

Si.
to Marco van de Voort

so how would one do say echo "hello world" | freepascal-program

Is that possible on FreeBSD ?

Si.

Show quoted text 40 lines
-----Original Message----- From: Behalf Of Marco van de Voort Sent: 08 March 2001 18:59 To: Subject: Re: [fpc-pascal]Read STIN on FreeBSD > Perhaps I misunderstand the question, > > but couldn't you use Readln, read, or keypressed/readkey? (if you use the > CRT unit). Under most systems (and Pascals), stdin is assigned to be the > default for readln (and likewise stdout for writeln). So, to read in a > string from the standard input, you could use: > > var > st:string; > begin > readln(st); > end; > > > If you were looking for a charicter by charicter basis, you could use > readkey. If you need more examples, let me know. It is possible to use readkey under FreeBSD, but from the ncrt unit, not the CRT unit. The Linux Crt unit is very Linux specific, and was not portable to FreeBSD. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Jonas
Si. wrote
so how would one do say echo "hello world" | freepascal-program
program HelloWorld;
begin
  writeln('Hello World!');
end.

Jonas

Reply by email

Si.
to Jonas

I think you miss the point of what i want.

I was to be able to read from stdin. i.e. i want to be able to pipe '|' data into a program. That was purely an example. I would assume this is quite a trvial thing to do but as of yet i havent been able to figure it out.

Thanks,

Si.

Show quoted text 26 lines
-----Original Message----- From: Behalf Of Jonas Sent: 08 March 2001 19:24 To: Subject: RE: [fpc-pascal]Read STIN on FreeBSD On Thursday, March 8, 2001, at 08:17 PM, Si. wrote: > so how would one do say echo "hello world" | freepascal-program program HelloWorld; begin writeln('Hello World!'); end. Jonas _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Unknown author
to Si.
Si. wrote 5 lines
I think you miss the point of what i want. I was to be able to read from stdin. i.e. i want to be able to pipe '|' data into a program. That was purely an example. I would assume this is quite a trvial thing to do but as of yet i havent been able to figure it out.

What about a simple

program readsomething;
Var
  S : String;
begin
  While not EOF do
    begin
    readln(s);
    writeln('Got : ',S);
    end;
end.

I would think this is basic pascal syntax.

Michael.

Reply by email

Si.
to Marco van de Voort

Oops, sorry it was my testing that have been echo "hello world" | ./freepascal-program. no wonder it didnt work, hehe.

Thanks for all your help guys, thats another util written. FreePascal is by the far the best language for doing unix sysadm type stuff :)

Show quoted text 30 lines
-----Original Message----- From: Behalf Of Marco van de Voort Sent: 08 March 2001 21:33 To: Subject: Re: [fpc-pascal]Read STIN on FreeBSD > so how would one do say echo "hello world" | freepascal-program > > Is that possible on FreeBSD ? Sure, no problem. The CGI's even function that way. E.g. : var c : Char; begin While not EOF(input) DO begin read(c); write(c); end; end. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Jonas
Si. wrote 5 lines
I think you miss the point of what i want. I was to be able to read from stdin. i.e. i want to be able to pipe '|' data into a program. That was purely an example. I would assume this is quite a trvial thing to do but as of yet i havent been able to figure it out.

Then look at the code in the previous mail I sent.

Jonas

Reply by email

Anderson R. Livramento
to Si.: Oops, sorry it was my testing that have been echo "hello world" | ./freepascal-program. …

Hello,

I'm writing a program in fpc for Linux, using a connection to mysql, but I need the "libmysqlclient" of Red Hat Linux 5.0 [Hurricane]. Does anybody know where I find it, because others "libs" versions do not work on Red Hat 5.0

Thanks for help.

,o888b,`?88888 Anderson R. Livramento
,8888 888 ?888 REDES E CONECTIVIDADE - Pesquisa & Desenvolvimento 8888888P' 888 Digilab S.A - Solucoes digitais
888P' 888 Florianopolis - SC - Brasil
`88 O d888 http://www.digilab.com.br
`?._ _.o888888888888888888888888888888888888888888888888888888888 "Onde quer que vc esteja, vc sempre estara la."

Reply by email

Johan Blok
to Anderson R. Livramento
"Anderson R. Livramento" wrote 6 lines
Hello, I'm writing a program in fpc for Linux, using a connection to mysql, but I need the "libmysqlclient" of Red Hat Linux 5.0 [Hurricane]. Does anybody know where I find it, because others "libs" versions do not work on Red Hat 5.0

It's very simple to compile MySQL your self after downloading the source. You don't
have to give any options. Simply run configure and make.

Johan

Reply by email