Solved

SH & PERL, Easy newbie question

Posted on 1998-11-26
3
177 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
  • 2
3 Comments
 
LVL 4

Expert Comment

by:davidmwilliams
Comment Utility
 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
Comment Utility
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
Comment Utility
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 to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
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.
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now