Solved

SH & PERL, Easy newbie question

Posted on 1998-11-26
3
183 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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
The viewer will learn how to count occurrences of each item in an array.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

740 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