Perl CGI executing command line functions

  • Permalink
  • submit to reddit
  • Email
  • Follow


I am just starting out with Perl and am trying to figure out how to
setup a CGI script to perform some command line functions.  I work
with some people that need to run some command line functions but we
do not want to give them command line access.  I thought that if I
write a Perl CGI script that executes some of the commands for them,
it would solve our problems.

I have found tons of examples and tutorials that show you how to get a
Perl CGI to write to files, display HTML pages and print lines.  What
is the correct syntax for backticks in Perl?  My goal was to give them
allow
them access to some HTML pages with some forms where they enter the
options for certain commands.

For example, if I had this as my HTML form and the user entered "-al"
<form action="dosomething.cgi" method="GET">  
Enter an #ls option:  <input type="text" name="commd" size=30><p>
<input type="submit">
</form>  

How would I get Perl to run that #ls command with the user's option
values (#ls -al) and display the end result of that command?
Would it be something similar to 
`ls` $commd;
How would I show the end result?

Thanks in advance,
Nick
0
Reply kvetchv (1) 10/1/2003 9:07:57 PM

See related articles to this posting


In article <3eb8c8ea.0310011307.6f17ae73@posting.google.com>,
 kvetchv@yahoo.com (Nick) wrote:

> I am just starting out with Perl and am trying to figure out how to
> setup a CGI script to perform some command line functions.  I work
> with some people that need to run some command line functions but we
> do not want to give them command line access.  I thought that if I
> write a Perl CGI script that executes some of the commands for them,
> it would solve our problems.
> 
> I have found tons of examples and tutorials that show you how to get a
> Perl CGI to write to files, display HTML pages and print lines.  What
> is the correct syntax for backticks in Perl?  My goal was to give them
> allow
> them access to some HTML pages with some forms where they enter the
> options for certain commands.
> 
> For example, if I had this as my HTML form and the user entered "-al"
> <form action="dosomething.cgi" method="GET">  
> Enter an #ls option:  <input type="text" name="commd" size=30><p>
> <input type="submit">
> </form>  
> 
> How would I get Perl to run that #ls command with the user's option
> values (#ls -al) and display the end result of that command?
> Would it be something similar to 
> `ls` $commd;
> How would I show the end result?
> 
> Thanks in advance,
> Nick

the most naive way would be this:

#----------------------------------------
#!perl -w

use strict;
use CGI qw/:standard/;

$|++;

print header();

my $commd = param('commd');

print `ls $commd`;
#----------------------------------------

however... think of what would happen if the user entered "; rm -fr *.*" 
!!!!!!!

you might wanna constrain what is allowable...
-- 
Michael Budash
0
Reply Michael 10/1/2003 9:24:25 PM

It was a dark and stormy night, and Nick managed to scribble:

> I am just starting out with Perl and am trying to figure out how to
> setup a CGI script to perform some command line functions.  I work
> with some people that need to run some command line functions but we
> do not want to give them command line access.  I thought that if I
> write a Perl CGI script that executes some of the commands for them,
> it would solve our problems.

Use the 'system' command. You will probably nned fully qualified paths if you use CGI.

gtoomey
0
Reply Gregory 10/1/2003 9:26:37 PM

Nick wrote:
> I work with some people that need to run some command line
> functions but we do not want to give them command line access.  I
> thought that if I write a Perl CGI script that executes some of the
> commands for them, it would solve our problems.

*Some* of the commands? Do they have access to upload and run their
own CGI scripts? In that case, what prevents them from uploading a
script and executing *any* system command?

Just a thought.

> For example, if I had this as my HTML form and the user entered
> "-al"
> <form action="dosomething.cgi" method="GET">
> Enter an #ls option:  <input type="text" name="commd" size=30><p>
> <input type="submit">
> </form>
> 
> How would I get Perl to run that #ls command with the user's option
>  values (#ls -al) and display the end result of that command?
> Would it be something similar to
> `ls` $commd;
> How would I show the end result?

An example:

     $result = `ls $commd 2>&1`;

The '2>&1' part makes it capture also possible error messages in $result.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

0
Reply Gunnar 10/1/2003 9:31:38 PM

Nick <kvetchv@yahoo.com> wrote:

> I am just starting out with Perl and am trying to figure out how to
> setup a CGI script 


You should learn Perl itself first, before moving on to a
complicated application area such as CGI programs.


> to perform some command line functions.  I work
> with some people that need to run some command line functions but we
> do not want to give them command line access.  


Why is it that you do not want to give them command line access?


> I thought that if I
> write a Perl CGI script that executes some of the commands for them,
> it would solve our problems.


It seems much more likely to me to _cause_ more problems
that it solves.

I think we have an XY problem.

If you can answer the question above, we will be in a much better
postion to give good advice...


> How would I get Perl to run that #ls command 



What is the "#ls" command?


> with the user's option


You better turn taint checking on (-T) and check the user's input
very very carefully. You have lots of chances of opening up a
security hole with your idea. Be careful.


> values (#ls -al) and display the end result of that command?
> Would it be something similar to 
> `ls` $commd;


Assuming that $commd has somehow gotten the corresponding value
from the form, hopefully by calling CGI::param():

   my $result = `ls $commd`;


> How would I show the end result?

   print $result;

If it is in a CGI program where the output is supposed to go
to STDOUT anyway, then you do not need to capture the output
at all:

   print "Content-type: text/plain\n\n";
   system "ls $commd";


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas
0
Reply tadmc 10/1/2003 11:08:22 PM

Thanks guys.

tadmc@augustmail.com (Tad McClellan) wrote in message 
> You should learn Perl itself first, before moving on to a
> complicated application area such as CGI programs.

sounds like a fine idea and I intend to do this but I was hoping I
could pick up enough to write this CGI program
> 
> Why is it that you do not want to give them command line access?
> 
Our company has a policy that does not allow departments other than IT
to have command line access to the app servers.  Another department in
our company uses a program that makes additions/changes to one of our
app servers & database and the only current way to make these specific
changes is for them to put in a request with the IT department to
manually type in this application's script.
>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in message news:<blfh4d$bgeu8$1@ID-184292.news.uni-berlin.de>...
> *Some* of the commands? Do they have access to upload and run their
> own CGI scripts? In that case, what prevents them from uploading a
> script and executing *any* system command?
> 
Yes, they do have this control but since they are part of our company
we trust them and the app server and database is their equipment, we
just run/houses/configure so it is unlikely they will do harm to their
own machines
> 
> 
> An example:
> 
>      $result = `ls $commd 2>&1`;
> 
> The '2>&1' part makes it capture also possible error messages in $result.

Thanks!

Gregory Toomey <nospam@bigpond.com> wrote in message news:<1211198.pjaMW0z05n@gregs-web-hosting-and-pickle-farming>...
> It was a dark and stormy night, and Nick managed to scribble:
> 
Aaaaah, the story of my life.

Michael Budash <mbudash@sonic.net> wrote in message news:<mbudash-00DE11.14242401102003@typhoon.sonic.net>...

> the most naive way would be this:
> 
> #----------------------------------------
> #!perl -w
> 
> use strict;
> use CGI qw/:standard/;
> 
> $|++;
> 
> print header();
> 
> my $commd = param('commd');
> 
> print `ls $commd`;
> #----------------------------------------
> 
> however... think of what would happen if the user entered "; rm -fr *.*" 
> !!!!!!!
> 
> you might wanna constrain what is allowable...


We would restrict them to only certain commands.  While that doesn't
mean that they couldn't put a pipe in the options and enter a 2
commands at once but it is unlikely they would try to do any harm.
Thanks for the help!
0
Reply kvetchv 10/2/2003 1:25:27 PM

On Thu, 2 Oct 2003, Nick wrote:

> sounds like a fine idea and I intend to do this but I was hoping I
> could pick up enough to write this CGI program

As others have already warned you in various ways: you seem to be
setting yourself up for a security compromise.

Don't misunderstand me: there's nothing wrong with playing around and
exploring the capabilities of your various tools, and everybody needs
to make a start somewhere;  but for a serious production application
you _do_ need a sound grasp of the components (Perl, CGI,
security...), and it seems to me that you are playing with fire if you
attempt it with less.  I'm not sure that I'd want to trust myself to
get that sort of thing right without some aggressive peer-review, and
I've been dealing with computers, off and on, since 1958.

It isn't a simple matter of "trusting" the users: maybe they hadn't
appreciated the consequences of their well-intentioned actions, but if
you haven't screened them effectively enough from the dangerous bits
them the result would be as bad, irrespective of their intentions in
the matter.  Isn't that why the company policy is to keep them away
from the command line in the first place, after all?
0
Reply Alan 10/2/2003 2:53:36 PM

kvetchv@yahoo.com (Nick) writes:

> tadmc@augustmail.com (Tad McClellan) wrote in message 

> > Why is it that you do not want to give them command line access?
> > 
> Our company has a policy that does not allow departments other than IT
> to have command line access to the app servers.

This reminds me of something that I've heard of happening in a number
of places in one form or another.

The basic senario comes down to this.

Someone in a company decides that some resource needs to be protected
from the masses.  So the rooms containing that resource have their
locks changed.  The minions are not given keys to the rooms where the
valuable resource is housed.

However, in order to do their jobs the minions need to use the
resource.  The solution is to hang a key to the secure rooms in a
place where everyone (including visitors without even the minions'
keys) can get to it.  

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\
0
Reply Brian 10/2/2003 4:50:59 PM

In article <3eb8c8ea.0310020525.374773b9@posting.google.com>,
	kvetchv@yahoo.com (Nick) writes:
> Thanks guys.
> 
> tadmc@augustmail.com (Tad McClellan) wrote in message 
>> You should learn Perl itself first, before moving on to a
>> complicated application area such as CGI programs.
> 
> sounds like a fine idea and I intend to do this but I was hoping I
> could pick up enough to write this CGI program

This can all be done, and has been done safely before, and even presented
in this forum before.  But the basics are:

By allowing an input field for a user to type into, you are subject to
stuff like this:

enter arguments to ls:  -l ; cat /etc/passwd

See what I mean?

The best way to do this is with a pull down list, checkboxes, or something
similar.  If you allow an input field, you have just allowed acces to the
system.  If the list of things that they need to do is larger than the
scope of a list, then you need to provide them an account.  At LEAST a 
web account that they must log in with before using your tool.  You would
also want your tool to log actions taken by userid.

Collecting process accounting for individual accounts is MUCH safer than
trying to figure out which IP was connected to the web server at the time
of the 'problem'.

Some years ago I did an application for the help desk that allowed them to
run common commands on any system in the data center by clicking on a web
page.  It was used for first level system check before escalation.  It
used secure shell from a trusted host, and some of the commands needed to
be run as root (vxdisk list, for example).  The only way that this can be
done safely, is to define a finite set of commands that they will use, and
build forms that allow options by selection ONLY.  Never an input field.

The cgi scripts that run these commands must have rigid checks of the fields
that they are passed.  Even though they were hard coded in the forms, users
could figure out which cgi scripts are being called and try to pass them
commands directly.

Hope this helps.
0
Reply x0pmeyer 10/3/2003 8:36:45 AM

Phil Meyer wrote:

[snip]

> This can all be done, and has been done safely before, and even presented
> in this forum before.  But the basics are:
> 
> By allowing an input field for a user to type into, you are subject to
> stuff like this:
> 
> enter arguments to ls:  -l ; cat /etc/passwd
> 
> See what I mean?
> 
> The best way to do this is with a pull down list, checkboxes, or something
> similar.  If you allow an input field, you have just allowed acces to the
> system.  If the list of things that they need to do is larger than the
> scope of a list, then you need to provide them an account.  At LEAST a 
> web account that they must log in with before using your tool.  You would
> also want your tool to log actions taken by userid.

I have a question about whether an input field is any more secure than a 
pull-down list/checkbox. Even though the form is hard-coded can't 
aynyone submit pretty much anything they want, for example with LWP?

> Collecting process accounting for individual accounts is MUCH safer than
> trying to figure out which IP was connected to the web server at the time
> of the 'problem'.
> 
> Some years ago I did an application for the help desk that allowed them to
> run common commands on any system in the data center by clicking on a web
> page.  It was used for first level system check before escalation.  It
> used secure shell from a trusted host, and some of the commands needed to
> be run as root (vxdisk list, for example).  The only way that this can be
> done safely, is to define a finite set of commands that they will use, and
> build forms that allow options by selection ONLY.  Never an input field.
> 
> The cgi scripts that run these commands must have rigid checks of the fields
> that they are passed.  Even though they were hard coded in the forms, users
> could figure out which cgi scripts are being called and try to pass them
> commands directly.

This is more what I thought you are supposed to do with CGI - rigidly 
check all fields passed to the form - the person who builds the form 
specifies a set of *acceptable* parameters, and anything that does not 
fall in the defined set gets ignored, calls an error routine, etc. In 
other words, all form element are equally not secure.

Please correct me if I am making any incorrect assumptions.

thanks - keith

0
Reply ko 10/3/2003 9:22:41 AM

On Fri, 3 Oct 2003, ko wrote:

> I have a question about whether an input field is any more secure than a
> pull-down list/checkbox.

I have an answer, and it would be on-topic for
comp.infosystems.www.authoring.cgi because there's nothing
Perl-specific in it...

> Even though the form is hard-coded can't
> aynyone submit pretty much anything they want, for example with LWP?

Correct.

[...]
> Please correct me if I am making any incorrect assumptions.

About the appropriate group to post to, see above.

About the topic, see Lincoln Stein's web security FAQ.

But basically, as to content you seem to be on the right lines.

0
Reply Alan 10/3/2003 10:31:12 AM

Alan J. Flavell wrote:

> On Fri, 3 Oct 2003, ko wrote:
> 
> 
>>I have a question about whether an input field is any more secure than a
>>pull-down list/checkbox.
> 
> 
> I have an answer, and it would be on-topic for
> comp.infosystems.www.authoring.cgi because there's nothing
> Perl-specific in it...
> 

[snip]

> 
>>Please correct me if I am making any incorrect assumptions.
> 
> 
> About the appropriate group to post to, see above.
> 
> About the topic, see Lincoln Stein's web security FAQ.

Thanks for the advice, I've already read the FAQ. I guess my overly 
subtle (bad) attempt to give the OP a hint that he should check *all* 
form element parameters should have been posed as statements rather than 
questions.

And actually, a little over a year ago you were generous enough to help 
me when I was writing my "First CGI script". Although I admit at least I 
posted snippets of code :)

0
Reply ko 10/3/2003 11:20:41 AM

ko <kuujinbo@hotmail.com> wrote in message news:<bljf8i$bg1$1@pin3.tky.plala.or.jp>...
> Phil Meyer wrote:
> 

> I have a question about whether an input field is any more secure than a 
> pull-down list/checkbox. Even though the form is hard-coded can't 
> aynyone submit pretty much anything they want, for example with LWP?
> 
> > Collecting process accounting for individual accounts is MUCH safer than
> > trying to figure out which IP was connected to the web server at the time
> > of the 'problem'.
> > 

(OT)

Linux has Webmin to do all that you are asking in its CGI 'shell'
feature:

http://www.webmin.com

--and I think that some of their code can be adapted to do what you
want.

However, this is not really Perl, and, I think allowing anyone out
there on the Web to use either Webmin or your equivalent of an
arbitrary command line is __very very__ unwise. IMHO, Webmin is best
confined _behind_ a firewall.
0
Reply wherrera 10/3/2003 1:27:46 PM

Thanks for all your comments.  I will definitely look into all the
possibilities before I commit to anything, everyone has given me a lot
to look into.  Even though there will be someone that reviews and
corrects any flaws in my CGI script (that person just doesn't have the
time right now to write the script so I thought I would try it and
learn a little Perl in the meantime) I will study up on some Perl
before I attempt to jump into this.  A friend gave me a Perl book to
read, so I will study up on that and then come back with some more
questions.

Thanks,
Nick
0
Reply kvetchv 10/3/2003 2:07:57 PM

Nick <kvetchv@yahoo.com> wrote:

> A friend gave me a Perl book to
> read


Which one?

There are lots of poor Perl books.

Tell us which one you have, and we'll tell you if it's good or not.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas
0
Reply tadmc 10/3/2003 3:05:11 PM
comp.lang.perl.misc 32793 articles. 7 followers. Post

14 Replies
498 Views

Similar Articles

[PageSpeed] 25


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

Permission denied trying to execute shell commands from Perl/CGI.
Hi, I just installed Apache and I am trying to call a script that should output some stuff to my browser. I can't get this to work at all. Simple script #! /usr/bin/perl -w print "Content-type:text/html\n\n"; print `ls`; The screen is blank. httpd logs indicate permission denied ... [Tue Aug 22 14:54:32 2006] [error] [client 172.25.31.80] ls: ., referer: http://salrhellog01/maillog/ [Tue Aug 22 14:54:32 2006] [error] [client 172.25.31.80] : Permission denied, referer: http://host/log/ Any idea? The script works just fine locally, but not via the web. I tried exec and sy...

Perl CGI script to emulate a shell command line window
You have a Windows machine with a Perl interpreter (ActivePerl from ActiveState for example). You have FTP access to a Linux box with a Perl CGI script engine (typically, the box where your website is hosted) But you are very frustrated because you do not have a TELNET or a SSH access to this box, it would be much more easy to zip or untar your files... The solution we suggest you is to create two scripts, a CGI wich will run on the server and a Perl script that will run locally in a command line window. The local software will send commands to your CGI in an HTTP request, the CGI will interpr...

varargin in executable function fails for more than one argument on the command line
Relatively new to matlab. I have a function myfunc (varargin). The function executes properly from inside of matlab with a variable number of arguments. I have built an executable of this exact function (using mcc -c) but when I try to execute it from a command line with more than one argument I get the "too many input arguments" error. Can someone tell me what I am doing incorrectly and/or how to parse the one argument from the nt command line into the varargin cell array ...

Permission denied trying to execute shell commands from Perl/CGI on Apache.
Hi, I just installed Apache and I am trying to call a script that should output some stuff to my browser. I can't get this to work at all. Simple script #! /usr/bin/perl -w print "Content-type:text/html\n\n"; print `ls`; The screen is blank. httpd logs indicate permission denied ... [Tue Aug 22 14:54:32 2006] [error] [client 172.25.31.80] ls: ., referer: http://salrhellog01/maillog/ [Tue Aug 22 14:54:32 2006] [error] [client 172.25.31.80] : Permission denied, referer: http://host/log/ Any idea? The script works just fine locally, but not via t...

Perl CGI.pm, additional path information, and command line debugging
comp.infosystems.www.authoring.cgi: I am working on some Perl CGI scripts that use "additional path information". For example, if the user clicks on the following HTML link: <A HREF="/cgi-bin/randompicture.cgi/dpchrist/images">demo</A>: It results in the script randompicture.cgi being called with "dpchrist/images" as the additional path information. The script can fetch this additional path information via $ENV{'PATH_INFO'}, $ENV{'PATH_TRANSLATED'}, and the corresponding CGI.pm functions: my $path = path_trans...

command line execution and gui execution in paralell
Is it possible to setup a program to run through command-line interface, and control this program via the command-line while also having it open for control via user interface.&nbsp; If I understand correctly, setting a program to run through command-line interface precludes it from being controlled in parallel via user interface (i.e. having it open in labview like regular).&nbsp; I appreciate all feedback. Cheers! Are you trying to open a second instance of the same program while you have launched one from the command line or are you trying to open a VI from the command line (passin...

HELP -- execute some scripts from the command line as a command??????
Here is my problem sirs. I have to execute some scripts from the command line as a command. The scripts works very well when I run from a file in a well formated way as shown below. CRON_PATH=/var/spool/cron/crontabs for i in `ls $CRON_PATH`; do echo "\n-=[ Crontab entry for user $i ]=-\n" # crontab -l $i # does not work with HPUX 10.xx cat $CRON_PATH/$i | grep -v ^# done ; My problem is, how do I run these scripts as a single command from the command line. What my application does is it writes the commands to a temp file and then runs it from there. I need to...

Command-line SSH: Executing Shell Commands
I'm experiencing difficulty trying to execute the followng command-line ssh: ssh user@server sh -c "awk '{if (\$0 ~ \"^Mem:\") printf(\"%.2f\n\", \$3/\$2)}' /proc/meminfo" I understand that it's likely an issue of escape characters but having tried nearly every permutation that I can think of to no avail, have reached an impasse. Can someone tell me how to remotely execute this awk command via a command-line ssh without having to create a script on the remote end? Thanks. In article <155cf728.0409081346.4d48e779@posting.google.com>, Scot...

Strange Perl line : Return the result of a function to a function
I never done a Perl code before but I done some C, PHP, JAVA, etc... Peel looked very similar before I failed to understand those lines : substr($y, 5, 2) = substr($y, 4, 2); substr($y, 4, 1) = "."; How that possible ? It is replacing the 2 char at pos 5 with 2 char at pos 4 ? Thanks to help me put my eyes back in their hole. AlexHWGUY wrote: > I never done a Perl code before but I done some C, PHP, JAVA, etc... > Peel looked very similar before I failed to understand those lines : >=20 > substr($y, 5, 2) =3D substr($y, 4, 2); > substr($y, 4, 1) =3D ".";...

Command Line single execution of a line(s) of code
I installed perl for WIN from ActiveState D:\study\perl>perl -v This is perl, v5.8.6 built for MSWin32-x86-multi-thread (with 3 registered patches, see perl -V for more detail) Copyright 1987-2004, Larry Wall .... And I was going to try to test some code from: http://www.perldoc.com/perl5.8.4/pod/func/split.html Q: let's say I wanted to run a single line of code such as: print join(':', split(/ */, 'hi there')); .... should I be able to run if from the command line like: >perl -e print join(':', split(/ */, 'hi there')); Q: should produce...

how to execute an unix command from mozilla url command line
Hi How to execute an unix command from mozilla or any Linux based browser. Like rlogin to a remote server and then execute unix command, we need to execute this two operations from mozilla url. Please let me know any suggestions regarding this. Thanks dhamu <dhamodaran.baghavathi@gmail.com> writes: > Hi > > How to execute an unix command from mozilla or any Linux based > browser. > > Like rlogin to a remote server and then execute unix command, > we need to execute this two operations from mozilla url. > > Please let me know any suggestions rega...

Executing Multi-lines SQL Scripts From Command-line
Hello, I'm trying to execute a file containing few SQL statements. CREATE VIEW test1 AS SELECT * FROM table1; CREATE VIEW test2 AS SELECT * FROM table2; The standard SQL way is to end a statement with semi-colon. But doing that,it doesn't work in SQL Server. After changing ";" to "GO", it works fine. Is there anyway we can stick to ";" to indicate the end of statement. I don't want to create scripts which works only in SQL Server. Please comment. Thanks in advance. Simon Hayes (sql@hayes.ch) writes: > Neither the semi-colon nor GO are 'st...

can't run perl commands from command line
Greetings, I just installed perl v5.8.7 onto a 2003 server box. I can only seem to get perl -v to run on the command line only when I cd into the c:\perl\bin directory. >From the commad line at any other location I am getting the ... 'is not recognised as an internal or external command, operable program or batch file error'. I am plannign on running MRTG on this box and I am sort of new to perl. I got mrtg to run on one of my workstations with win2k but I am stumbling with this 2003 server. Is it an IIS issue? Is it a permissions issue? Thanks all! i'm not familiar wit...

CGI: Execute a perl script inside another perl script
Hello, I am using perl scripts as CGI. What I want to do is to call another perl script where I only set environment variables (envCGI.pl). If I set these variables in my initial perl script, it works well (I get my HTML page) but if I call the other perl script, I get: [12/Jan/2005:10:43:22] failure ( 632): for host 10.70.176.104 trying to POST /surcouf.cgi, cgi_scan_headers reports: HTTP4044: the CGI program C:\Perl\bin\perl.exe did not produce a valid header (program terminated without a valid CGI header. Check for core dump or other abnormal termination). Here is my perl script: #!C:...

A question about Perl: using perl command line to replace strings...
I have a quick question, how to change a string "abcd" to another string "xyabcd" in all the *.m (text) files under current directory? I defintely can write a perl script to do this. But I remember there is a most simple way of doing this using Perl. It is just "Perl xxxxxxxxxxxxxxxx" a command line with some options... It just escaped my memory, anybody knows how to do that please give me a hand! Thanks a lot. "lucy" <losemind@yahoo.com> wrote in news:ch550l$j1t$1@news.Stanford.EDU: > I have a quick question, how to change a string...

use one line Perl command to add a line at the begin of a file
Hallo all, I wanted to add a line (e.g #include "some.h") at the begin of all .c files in a directory. I try to change one .c file with one line Perl command perl -i.org -p -e 'BEGIN{print "#include \"some.h\"\n";}' But this doesn't work, "#include "some.h"" will be printed into STDOUT. I did it with a 'long' Perl script: my $f = shift; my $fm = $f.".org"; `touch $fm`; open F, $f or die "can not open file $f $!"; open FM, "> $fm" or die "can not open file $fm...

Putty command line : how to execute initialization commands and keep the session opened ?
Hello, I would like to make a batch (.bat file) that automatically opens several Putty sessions. No problem for the moment. But moreover I want to execute some specific commands for each session. I tried to use the -m option of the Putty command line to execute the commands set in a specified file but it seems that the Putty session is closed after the command are executed. Is there a way to do that ? Thank in advance. PS : the idea is to open a Putty session for each host where I have to check some logs, to go to the proper log directory and make a tail -f on a log file for instance....

CLI ( command-line ) PHP displaying source code in-line when program is executed
Hi all, I'm using PHP 4.4.2, and use PHP on both the command-line and the web. I am running PHP on SuSE 10 Linux , in a VMware 5.5 workstation, using Apache 2.0.55 , on my Dell laptop. Everything has been running flawlessly without problems. Very amazing to use VMware, it has worked beautifully. uname -a Linux xxxxxxx 2.6.13-15.8-default #1 Tue Feb 7 11:07:24 UTC 2006 i686 i686 i386 GNU/Linux php -v PHP 4.4.2 (cli) (built: Feb 7 2006 20:13:29) Copyright (c) 1997-2006 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies php -m [PHP Modules] bcmath bz2 calen...

Command Line Execution
I am just starting to learn TCL/TK I am using SuSE Linux 9.0 which has wish version 8.4 istalled. I can execute scripts if I type wish filename but I can not execute without first typing wish wish is in /usr/bin on my computer I have turned on the execute bit for the file. All I get is: command not found Below is an example #!/usr/bin/wish button .b -text "Hello World" -command {exit} pack .b Any ideas? In article <mkeUb.31$fS3.144121@news.abs.net>, Paul E. Lehmann <plehmann@fred.net> wrote: >I am just starting to learn TCL/TK >I am using SuSE Linux 9.0 wh...

executing from command line
Hey there, I have a perl script that i would like to run it on a windows server. Since there is no command line with windows, i want to execute script from a web page. Is that possible? Or am i just dreaming? "Monkey Man" <aktanaktas@earthlink.net> wrote in news:luuUb.9762$sQ3.5155@newssvr29.news.prodigy.com: > > Hey there, > I have a perl script that i would like to run it on a windows server. > Since there is no command line with windows, i want to execute script > from a web page. Is that possible? Or am i just dreaming? You seem to have no idea...

Calling cgi from cgi thru 'system' function. Different behaviour on browser v/s cmd line
Hi Im having trouble with the following code that seems to be behave differently when called from the browser as opposed to the command line. The calling script is a cgi that forks, with the child trying to call another cgi script and pass arguments to it. It works fine from the command line, and calls the required script and passes the arguments correctly. However, when it is run on the browser, it calls the script but does not pass the arguments to it. The called script (included) is also a cgi, set up to accept parameters via the param function. It accepts the parameters when the calling s...

Perl Command line for this problem
Hi, I am trying to use Perl command line for a bunch of sys admin tasks. I would like to do this: ------------------------ Read output from a perl -V command and grep for lines containing words starting with /usr or many spaces followed by /usr then search these lines (each line will be a directory starting with /usr or spaces and then /usr) for a filename (dogs.dat) How can I do this efficiently with perl command line (perl -i -pi etc ). Thanks, T tweetiebirds@gmail.com wrote: > > I am trying to use Perl command line for a bunch of sys admin tasks. > > I would like to do...

join lines
What is the perl command to join lines ? I appreciate your help. linelineline\newline (line1) lineline\newline (line2) linelinelineline\newline (line3) & rowrowrow\newline (line1) rowrow\newline(line2) row\newline(line3) & whateverwhatever(line1) whateverwhatever(line2) whatever(line3) Result linelineline&rowrowrow&whateverwhatever\newline lineline&rowrow&whateverwhatever\newline linelinelineline&row&whatever\newline julia wrote: > What is the perl command to join lines ? I appreciate your help. > > linelineline\newline (line1) > lineline\newline...

Perl Command line for stat
I am trying to use a command line Perl �e to stat a file with in Solaris. I was looking for someone that can modify the line so it will work from a command line. I have not been able to figure out the right format to use. Can someone please help me with this. Perl �e �(stat($filename)) [10]' any suggestions On 7 Oct 2003 10:52:23 -0700 nos41@hotmail.com (nos) wrote: # I am trying to use a command line Perl _e to stat a file with in # Solaris. I was looking for someone that can modify the line so it # will work from a command line. I have not been able to figure out the # right format ...