Sponsored Content
Top Forums Shell Programming and Scripting here document to automate perl script that call script Post 302141785 by hogger84 on Monday 22nd of October 2007 10:15:21 AM
Old 10-22-2007
apparently it is due to the way perl buffer all 1024 bytes of stdin on the first call leaving it not readable for the rest subsequent calls.

I have replaced the
system("perl runtest.pl");

with
Code:
require "runtest.pl";

and all works
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to call a perl script from a shell script

I have a perl script,Test.pl which needs arguments from command line like test.pl arg1 arg2 arg3 how can i call it from a shell script (2 Replies)
Discussion started by: anumkoshy
2 Replies

2. Shell Programming and Scripting

Call a perl script inside a shell script

Hi all, I have the following snippet of code.. #!/bin/sh echo "run perl script............" #Run the verification script perl bill_ver echo " perl script completed....." echo "rename files......" #Remove from all file in the directories test, test1, test2, test3 for f in... (3 Replies)
Discussion started by: chriss_58
3 Replies

3. Shell Programming and Scripting

call shell script from perl cgi script problem

hi,, i have perl scipt with line : system('./try.sh $t $d $m'); in shell scipt try.sh i have the line: echo $1 its not printing value of $t that i hav passed..y is it so..i am running it from apache web server (2 Replies)
Discussion started by: raksha.s
2 Replies

4. Shell Programming and Scripting

Perl cgi script to call bash script?

Novice to perl here. I have created a simple web page in perl, with only one submit button. I would like to execute a bash script on the same server when this button is clicked on. Is this possible in perl? I have spent a few days researching this and am unable to find any useful information.... (0 Replies)
Discussion started by: pleonard
0 Replies

5. Shell Programming and Scripting

how to call a bash script using perl

Hi I m new to perl. I m trying to write a perl script that calls a bash script; does anyone have a script already that they can provide or help me out? Thanks a lot. (2 Replies)
Discussion started by: adnan786
2 Replies

6. Shell Programming and Scripting

How to call expect script from Perl

I have a Perl script sub.pl, and i want to call another Expect script called sub.exp. The sub.exp will generate a text file called sub.txt, while the sub.pl called from a html form will display the content of sub.txt to the textarea on the html form. How do I call sub.exp from sub.pl??? ... (5 Replies)
Discussion started by: cxbest
5 Replies

7. Shell Programming and Scripting

shell script to call perl script problems

Ok, don't ask me why, but all calls to perl must be called by a shell script. Its really not ideal, but its what I have to work with. Calling it isnt the issue, its passing in the arguments. I have about 1000 perl scripts to call by a shell script. Right now, I'm executing the shell script... (3 Replies)
Discussion started by: regexnub
3 Replies

8. Shell Programming and Scripting

Perl script for taking inputs from one script and storing them into a document.

Hi. I wanted to create a Perl script which can take the outputs of a Perl script as it's input and temporarily store them in a document. Need help. Thanks.:) (8 Replies)
Discussion started by: xtatic
8 Replies

9. Shell Programming and Scripting

Call .profile in perl script

Hello Gurus Can anyone please let me know how to call .profle file in perl script When I am calling the .profile file its giving error Shall I create unix script which has .profile command and call perl script internally (2 Replies)
Discussion started by: Pratik4891
2 Replies

10. Shell Programming and Scripting

Call a Perl script within a bash script and store the ouput in a .txt file

I'm attempting to write a bash script that will create a network between virtual machines. It accepts three arguments: an RSpec that describes the network topology, and two list of machines (servers and clients). I have a (working) Perl script that I want to call. This Perl script takes an RSpec... (6 Replies)
Discussion started by: mecaka
6 Replies
Encode::PerlIO(3pm)					 Perl Programmers Reference Guide				       Encode::PerlIO(3pm)

NAME
Encode::PerlIO -- a detailed document on Encode and PerlIO Overview It is very common to want to do encoding transformations when reading or writing files, network connections, pipes etc. If Perl is configured to use the new 'perlio' IO system then "Encode" provides a "layer" (see PerlIO) which can transform data as it is read or written. Here is how the blind poet would modernise the encoding: use Encode; open(my $iliad,'<:encoding(iso-8859-7)','iliad.greek'); open(my $utf8,'>:utf8','iliad.utf8'); my @epic = <$iliad>; print $utf8 @epic; close($utf8); close($illiad); In addition, the new IO system can also be configured to read/write UTF-8 encoded characters (as noted above, this is efficient): open(my $fh,'>:utf8','anything'); print $fh "Any x{0021} string N{SMILEY FACE} "; Either of the above forms of "layer" specifications can be made the default for a lexical scope with the "use open ..." pragma. See open. Once a handle is open, its layers can be altered using "binmode". Without any such configuration, or if Perl itself is built using the system's own IO, then write operations assume that the file handle accepts only bytes and will "die" if a character larger than 255 is written to the handle. When reading, each octet from the handle becomes a byte-in-a-character. Note that this default is the same behaviour as bytes-only languages (including Perl before v5.6) would have, and is sufficient to handle native 8-bit encodings e.g. iso-8859-1, EBCDIC etc. and any legacy mechanisms for handling other encodings and binary data. In other cases, it is the program's responsibility to transform characters into bytes using the API above before doing writes, and to transform the bytes read from a handle into characters before doing "character operations" (e.g. "lc", "/W+/", ...). You can also use PerlIO to convert larger amounts of data you don't want to bring into memory. For example, to convert between ISO-8859-1 (Latin 1) and UTF-8 (or UTF-EBCDIC in EBCDIC machines): open(F, "<:encoding(iso-8859-1)", "data.txt") or die $!; open(G, ">:utf8", "data.utf") or die $!; while (<F>) { print G } # Could also do "print G <F>" but that would pull # the whole file into memory just to write it out again. More examples: open(my $f, "<:encoding(cp1252)") open(my $g, ">:encoding(iso-8859-2)") open(my $h, ">:encoding(latin9)") # iso-8859-15 See also encoding for how to change the default encoding of the data in your script. How does it work? Here is a crude diagram of how filehandle, PerlIO, and Encode interact. filehandle <-> PerlIO PerlIO <-> scalar (read/printed) / Encode When PerlIO receives data from either direction, it fills a buffer (currently with 1024 bytes) and passes the buffer to Encode. Encode tries to convert the valid part and passes it back to PerlIO, leaving invalid parts (usually a partial character) in the buffer. PerlIO then appends more data to the buffer, calls Encode again, and so on until the data stream ends. To do so, PerlIO always calls (de|en)code methods with CHECK set to 1. This ensures that the method stops at the right place when it encounters partial character. The following is what happens when PerlIO and Encode tries to encode (from utf8) more than 1024 bytes and the buffer boundary happens to be in the middle of a character. A B C .... ~ x{3000} .... 41 42 43 .... 7E e3 80 80 .... <- buffer ---------------> << encoded >>>>>>>>>> <- next buffer ------ Encode converts from the beginning to x7E, leaving xe3 in the buffer because it is invalid (partial character). Unfortunately, this scheme does not work well with escape-based encodings such as ISO-2022-JP. Line Buffering Now let's see what happens when you try to decode from ISO-2022-JP and the buffer ends in the middle of a character. JIS208-ESC x{5f3e} A B C .... ~ e $ B |DAN | .... 41 42 43 .... 7E 1b 24 41 43 46 .... <- buffer ---------------------------> << encoded >>>>>>>>>>>>>>>>>>>>>>> As you see, the next buffer begins with x43. But x43 is 'C' in ASCII, which is wrong in this case because we are now in JISX 0208 area so it has to convert x43x46, not x43. Unlike utf8 and EUC, in escape-based encodings you can't tell if a given octet is a whole character or just part of it. Fortunately PerlIO also supports line buffer if you tell PerlIO to use one instead of fixed buffer. Since ISO-2022-JP is guaranteed to revert to ASCII at the end of the line, partial character will never happen when line buffer is used. To tell PerlIO to use line buffer, implement ->needs_lines method for your encoding object. See Encode::Encoding for details. Thanks to these efforts most encodings that come with Encode support PerlIO but that still leaves following encodings. iso-2022-kr MIME-B MIME-Header MIME-Q Fortunately iso-2022-kr is hardly used (according to Jungshik) and MIME-* are very unlikely to be fed to PerlIO because they are for mail headers. See Encode::MIME::Header for details. How can I tell whether my encoding fully supports PerlIO ? As of this writing, any encoding whose class belongs to Encode::XS and Encode::Unicode works. The Encode module has a "perlio_ok" method which you can use before applying PerlIO encoding to the filehandle. Here is an example: my $use_perlio = perlio_ok($enc); my $layer = $use_perlio ? "<:raw" : "<:encoding($enc)"; open my $fh, $layer, $file or die "$file : $!"; while(<$fh>){ $_ = decode($enc, $_) unless $use_perlio; # .... } SEE ALSO
Encode::Encoding, Encode::Supported, Encode::PerlIO, encoding, perlebcdic, "open" in perlfunc, perlunicode, utf8, the Perl Unicode Mailing List <perl-unicode@perl.org> perl v5.16.2 2012-08-26 Encode::PerlIO(3pm)
All times are GMT -4. The time now is 08:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy