Re: puzzling results from missing she-bang

2002-04-29 Thread Michael Turner

Peter,

Thanks again. Now, I have it clear.

/Michael

>
>> Thanks for your response. I remain puzzled, however. Your response 
>> seems to imply that if I invoke "print" from the command line, it will 
>> be interepreted. This is not the case, it errors.
>
> Sure it will - if you are using the sh shell.  Try this:
>
> zany:~/unix/avr/avr/include% sh
> zany% print "hello";
> hello
> zany% exit
> zany:~/unix/avr/avr/include%
>
> (ie, type: shprint "hello";)
>
> Enjoy,
>Peter.




Re: puzzling results from missing she-bang

2002-04-28 Thread Peter N Lewis

At 22:09 -0400 28/4/02, Michael  Turner wrote:

>Thanks for your response. I remain puzzled, however. Your response 
>seems to imply that if I invoke "print" from the command line, it 
>will be interepreted. This is not the case, it errors.

Sure it will - if you are using the sh shell.  Try this:

zany:~/unix/avr/avr/include% sh
zany% print "hello";
hello
zany% exit
zany:~/unix/avr/avr/include%

(ie, type: shprint "hello";)

Enjoy,
Peter.

-- 
  



Re: puzzling results from missing she-bang

2002-04-28 Thread Michael Turner

>>
>> Note the missing "she-bang" line: #!/usr/bin/perl -w   Note also that I
>> didn't tell the shell "how" to execute the file. So the file is set to
>> executable, but I thought it should error. Is that line not necessary 
>> on
>> a Mac for some reason? How is this a Mac thing? It is not functional on
>> other unix  machines I have access to (and I tried various shells,
>> including tcsh & bash). I repeated the experiment with no ".pl"
>> extension, that isn't it.
>>
>> I suspect that it is a shell issue of some kind.
>>
>> /Michael Turner
>>
>
> Not an issue. No shebang line means that 'exec(2)' will invoke your 
> standard
> shell on it. 'print' is defined in some 'bash' or 'ksh' environments, 
> or you
> may have such an alias or local program.
>

Bob,

Thanks for your response. I remain puzzled, however. Your response seems 
to imply that if I invoke "print" from the command line, it will be 
interepreted. This is not the case, it errors.

/Michael Turner





Re: puzzling results from missing she-bang

2002-04-26 Thread Sherm Pendley

On Friday, April 26, 2002, at 07:41 PM, Sherm Pendley wrote:

> It appears that the shell, when asked to run something

D'oh!

s/shell/kernel/;

sherm--




Re: puzzling results from missing she-bang

2002-04-26 Thread Sherm Pendley

On Friday, April 26, 2002, at 07:21 PM, Michael Turner wrote:

> Note the missing "she-bang" line: #!/usr/bin/perl -w   Note also that I 
> didn't tell the shell "how" to execute the file. So the file is set to 
> executable, but I thought it should error. Is that line not necessary 
> on a Mac for some reason? How is this a Mac thing? It is not functional 
> on other unix  machines I have access to (and I tried various shells, 
> including tcsh & bash). I repeated the experiment with no ".pl" 
> extension, that isn't it.

I repeated your experiment, but with a .sh extension instead. It worked. 
Then, I ran the script with "sh test.sh" - again, it worked.

Then, I tried another script:

print $ENV{'HOME'};

The output was this:

{HOME}

Aha! That's the output that one would expect if $ENV{'HOME'} were 
evaluated in a shell script, rather than a Perl script.

It appears that the shell, when asked to run something that isn't a 
binary and has no shebang, defaults to running it as a shell script. As 
it happens, the output of your first test script is the same, regardless 
of whether it's run by the shell or by Perl.

sherm--

Never put off until tomorrow what you can do today. There might be a law 
against it by that time.




puzzling results from missing she-bang

2002-04-26 Thread Michael Turner

I performed a test, and was surprised by the results. Can anyone tell me 
why the result occurs?

File:
-rwxr-xr-x  1 mt  staff  25 Apr 26 19:07 hw.pl

contents:
print "Hello, World.\n";

command
../hw.pl

results:
Hello, World.

Note the missing "she-bang" line: #!/usr/bin/perl -w   Note also that I 
didn't tell the shell "how" to execute the file. So the file is set to 
executable, but I thought it should error. Is that line not necessary on 
a Mac for some reason? How is this a Mac thing? It is not functional on 
other unix  machines I have access to (and I tried various shells, 
including tcsh & bash). I repeated the experiment with no ".pl" 
extension, that isn't it.

I suspect that it is a shell issue of some kind.

/Michael Turner