LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-02-2007, 12:43 PM   #1
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

Rep: Reputation: 51
Possible to have perl code into bash script ?


example:
Code:
#/bin/bash
echo "this is bash script"
echo "--"
perl -e "
   
my perl commands

   use Shell qw(cat ps cp);
   $passwd = cat('</etc/passwd');
   @pslines = ps('-ww'),
   cp("/etc/passwd", "/tmp/passwd");

   # object oriented 
   my $sh = Shell->new;
   print $sh->ls('-l');


"
 
Old 07-02-2007, 01:17 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,395

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
well you've written a script there, have you tried it? should generally be fine as it's nothing more than a per one liner over a number of lines (apart from that "my perl commands" gubbins, oh and the fact that youre extenral " marks will clash with the internal ones.
 
Old 07-03-2007, 12:35 PM   #3
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by acid_kewpie
well you've written a script there, have you tried it? should generally be fine as it's nothing more than a per one liner over a number of lines (apart from that "my perl commands" gubbins, oh and the fact that youre extenral " marks will clash with the internal ones.
I found this EOF... in startfluxbox.

Could this code somehow work ?

Code:
#/bin/sh


echo "This is sh"

echo "this is perl code to begin"

( perl -e << EOF

print "hello" ;
print " This is perl";


my $filename = "tmp.htm";
$contents = `curl http://www.google.com  | grep current `;

open(F, $contents ) or die( "can't the file \n" );

$line = <F>; 
print $line ;
$line = <F>; 
print $line ;


{

print $line ;

} 

EOF
    ) 


echo "back to sh"

echo "script finished"
 
Old 07-03-2007, 12:56 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,395

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
you given complete two examples, yet haven't tried either... the second example is part of a fully functional script on your system, pretty likely it works just fine...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Perl vs. bash code - number of lines noir911 Programming 11 10-07-2011 12:35 PM
passing variable from bash to perl in a bash script quadmore Programming 6 02-21-2011 04:11 AM
Perl error in a Bash script rujin69 Programming 2 03-26-2007 02:40 PM
Help: Perl or Bash Script help embsupafly Programming 1 08-11-2005 06:01 PM
Embedding perl in bash script MikHud Programming 4 02-02-2005 06:26 AM


All times are GMT -5. The time now is 12:54 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration