SH & PERL, Easy newbie question

I've got a perl script that does things (not important what). ie. the file starts with:
#!/bin/perl
I want that same script to run a programs (lets say ls and uptime, for eg.), which I can make happen using first line:
#!/bin/sh

But stupid me can't combine those two..!  Please, HELP !

Script is intended to run in Unix from a webbrowser.
TManAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
davidmwilliamsConnect With a Mentor Commented:
Yes ! :)
Just use the system command ... e.g.

system 'cat /tmp/register.new >> /usr/local/ns-home/docs/it/register.reg';
0
 
davidmwilliamsCommented:
 What you want to do is quite right - if you wish to make a script that uses shell commands, specify the first line as invoking the appropriate shell.
  Are you saying that

#!/bin/sh
ls

  for example, does not work for you?  What is happening?  Presumably you are calling this as a CGI script - so maybe you need to check that the directory the script is in is defined as a cgi-bin directory in the Webserver, that any required file extensions (e.g. .cgi) are being used, that the script has execute permissions, that the script can be run successfully as the user who the Web server runs as, and so forth.
0
 
TManAuthor Commented:
davidmwilliams:
Yes that works.. but I need to use PERL commands (open, foreach, while, etc...) in that same script.
So would the better question be :
    Can I execute shell commands within PERL script ?
0
All Courses

From novice to tech pro — start learning today.