LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-28-2012, 05:29 AM   #1
lamletoi
Member
 
Registered: Oct 2011
Posts: 46

Rep: Reputation: Disabled
Help to solve perl run shell script


Hello all,
I have a problem when i try to run a script from perl script.
my perlscript:
PHP Code:
#/usr/bin/perl
print "Content-type: text/html\n\n";
system("sh myshell.sh"); 
my shellscript
PHP Code:
#!/bin/bash
lsof ---|sort >/tmp/tofile.txt 
perl and shell script can run ok but no output send to my file.
I do know what is problem?
i can run only shell script and its ok.
How do i solve this
 
Old 04-28-2012, 03:10 PM   #2
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,766
Blog Entries: 23

Rep: Reputation: 411Reputation: 411Reputation: 411Reputation: 411Reputation: 411
What are the execute rights, and the feedback of either script, please.
If you want to send something to a file from Perl, you'll need to define an output stream...

Thor
 
Old 04-30-2012, 01:13 AM   #3
lamletoi
Member
 
Registered: Oct 2011
Posts: 46

Original Poster
Rep: Reputation: Disabled
i set permission of myshell.sh to 777.
tofile.txt to 777.
i changed lsof->/usr/sbin/lsof too

i run ./ myshell.sh only.(below code) and its ok.the data show in /tmp/tofile.txt
PHP Code:
#!/bin/bash
lsof ---|sort >/tmp/tofile.txt 
and i run perl script
PHP Code:
#/usr/bin/perl
print "Content-type: text/html\n\n";
system("sh myshell.sh"); 
with myshell.sh
PHP Code:
#!/bin/bash
/usr/sbin/lsof >/tmp/tofile.txt 
Its ok too.

But when i try to add 1 or more options( -i -n -P) or
PHP Code:
#!/bin/bash
/usr/sbin/lsof |sort >/tmp/tofile.txt 
it did not do anything.
Nothing in /tmp/tofile.txt

Last edited by lamletoi; 04-30-2012 at 01:15 AM.
 
Old 05-01-2012, 07:56 AM   #4
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,766
Blog Entries: 23

Rep: Reputation: 411Reputation: 411Reputation: 411Reputation: 411Reputation: 411
Quote:
But when i try to add 1 or more options( -i -n -P) or
...I dont see the code that has to interpret the parameters, is there any of that? If so, try to set some feedback points in the code to see up to what point the code reaches. I suspect something to go wrong as you feed parameters, and the code crashes before reaching the point where it needs to write something to a file...

Thor
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
using Systme and exec to run shell script in perl program jlien Linux - Newbie 10 02-16-2012 12:06 AM
Perl experts: I need to run shell command from perl using pipe idreesedu Programming 14 01-11-2011 04:52 PM
run shell script from perl kzcom Linux - Networking 4 09-04-2010 07:30 AM
MySQL Updates With Null When Perl Script Run From Shell Script ThisGuyIKnow Programming 6 08-12-2008 09:56 AM
how to run a shell script in the perl script sharad Linux - General 1 05-24-2006 03:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration