Solved

SH & PERL, Easy newbie question

Posted on 1998-11-26
3
187 Views
Last Modified: 2013-12-25
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.
0
Comment
Question by:TMan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Expert Comment

by:davidmwilliams
ID: 1829801
 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
 

Author Comment

by:TMan
ID: 1829802
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
 
LVL 4

Accepted Solution

by:
davidmwilliams earned 100 total points
ID: 1829803
Yes ! :)
Just use the system command ... e.g.

system 'cat /tmp/register.new >> /usr/local/ns-home/docs/it/register.reg';
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question