LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 09-12-2013, 08:39 AM   #1
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Rep: Reputation: 30
add script


deleted

Last edited by ust; 09-25-2013 at 02:16 AM.
 
Old 09-12-2013, 08:49 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,129

Rep: Reputation: 2272Reputation: 2272Reputation: 2272Reputation: 2272Reputation: 2272Reputation: 2272Reputation: 2272Reputation: 2272Reputation: 2272Reputation: 2272Reputation: 2272
I do not understand how can you add a bash script to a perl program.
For a general bash script you can set #!/bin/bash as the very first line.
 
Old 09-12-2013, 09:53 AM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,950

Rep: Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693
Quote:
Originally Posted by ust View Post
I have a perl program , the first line is /usr/lib/perl , the script works fine , if I want to add bash shell script to it , what I need to do to make sure it can be run , I just need to add /bin/bash on the top of the program ?
thanks
ust, you have been a member here now for TEN YEARS...at what point are you going to begin to look things up and make an effort of your own?? There are THOUSANDS of VERY easily-found perl programming guides, and just putting "run a bash script from a perl program" into Google will (AMAZINGLY!!!) give you the answer. Even searching this very site will...did you bother to try ANY of that???

http://www.linuxquestions.org/questi...n-perl-925806/
http://stackoverflow.com/questions/1...-a-perl-script
http://perldoc.perl.org/functions/system.html
http://perl.about.com/od/programming...execsystem.htm
 
1 members found this post helpful.
Old 09-12-2013, 10:15 AM   #4
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Original Poster
Rep: Reputation: 30
deleted

Last edited by ust; 09-25-2013 at 02:16 AM.
 
Old 09-12-2013, 10:30 AM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,950

Rep: Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693
Quote:
Originally Posted by ust View Post
I just would like to confirm if can not run bash script in a perl program ?
why I want to do it is because the perl program is well developed , but I do not know how to modify perl program , so I just want to add bash script to it.

Thanks much.
Then read the links you were already spoon-fed. After TEN YEARS, you should be at least able to do that.
 
Old 09-12-2013, 10:32 AM   #6
eklavya
Member
 
Registered: Mar 2013
Posts: 619

Rep: Reputation: 136Reputation: 136
Quote:
Originally Posted by ust View Post
I just would like to confirm if can not run bash script in a perl program ?
Yes it is possible.
http://linuxpoison.blogspot.in/2012/...e-bash-or.html

Last edited by eklavya; 09-12-2013 at 10:33 AM.
 
Old 09-12-2013, 10:06 PM   #7
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Original Poster
Rep: Reputation: 30
deleted

Last edited by ust; 09-25-2013 at 02:16 AM.
 
Old 09-13-2013, 12:09 AM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
Please show us your ACTUAL code so far...
The 1st post says /usr/lib/perl, the latest shows /usr/bin/perl (more common) & you've skipped the '#!' ...
 
Old 09-13-2013, 04:29 AM   #9
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Original Poster
Rep: Reputation: 30
deleted

Last edited by ust; 09-25-2013 at 02:17 AM.
 
Old 09-13-2013, 04:35 AM   #10
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
Quote:
Originally Posted by ust View Post
I am not familiar with perl program , I guess the program should like this , could help to advise how to write this perl program ? thanks .

#!/usr/bin/perl
sub checkcontent {
system("/bin/bash /path/to/script");
check output ,if the output contains the string "warning"
then return 1
else
return 0
}
I don't know perl, but I'm pretty sure
Quote:
check output ,if the output contains the string "warning"
is junk

why do you not just get your bash script to return the correct code, then check the exit status of the perl system()

post your bash script
 
Old 09-13-2013, 09:18 AM   #11
bloodstreetboy
Member
 
Registered: May 2012
Posts: 198
Blog Entries: 3

Rep: Reputation: 37
Quote:
Originally Posted by ust View Post
#!/usr/bin/perl
sub checkcontent {
system("/bin/bash /path/to/script");
check output ,if the output contains the string "warning"
then return 1
else
return 0
}
Is this any type of test for experts?
I am not getting this.

Is the thread a trick question?

I am sorry but I am not able to digest the thread.

There is something fishy here but I am not able to catch it.
 
Old 09-13-2013, 10:12 AM   #12
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,950

Rep: Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693
Quote:
Originally Posted by bloodstreetboy View Post
Is this any type of test for experts? I am not getting this.

Is the thread a trick question? I am sorry but I am not able to digest the thread. There is something fishy here but I am not able to catch it.
Sadly, no. Check out the OP's other threads that go back ten years.
 
Old 09-14-2013, 02:57 PM   #13
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,950

Rep: Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693
Quote:
Originally Posted by ust View Post
I am not familiar with perl program , I guess the program should like this , could help to advise how to write this perl program ? thanks
Code:
#!/usr/bin/perl
sub checkcontent {
system("/bin/bash /path/to/script");
check output ,if the output contains the string "warning"
then return 1
else
return 0
}
We did 'advise', and in both your threads you've been pointed to both the "system" and "exec" functions in Perl. You've also been spoon-fed links to those pages...can you not read/understand them?? There are EXAMPLES on how to do what you want, or would you also like us to write the code for you, along with looking things up?

After TEN YEARS, and over a thousand posts, I don't think it's too much to ask that you actually try to research/do something on your own, especially after being fed examples.
 
Old 09-14-2013, 04:25 PM   #14
GNU/Linux
Member
 
Registered: Sep 2012
Distribution: Slackware-14
Posts: 118

Rep: Reputation: Disabled
You are right TBOne. After 10 years!

You can't teach an old dog new tricks.
 
Old 09-27-2013, 12:58 PM   #15
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531
Quote:
Originally Posted by TB0ne View Post
After TEN YEARS, and over a thousand posts, I don't think it's too much to ask that you actually try to research/do something on your own, especially after being fed examples.
It is.

And it is OK to try and nudge a longtime member once in a while.
But I notice by now you're repeating the message. Incessantly.
That is not good.
Please stop.
 
  


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
no script add-on DeepSeaNautilus Linux - Security 3 02-25-2009 04:42 PM
Add script to iptables Supporter1984 Slackware 1 05-06-2008 04:38 PM
add to a running script linuxhippy Slackware 3 09-02-2006 11:26 AM
add user script satinet Linux - General 2 10-21-2005 03:48 AM
How to add something in init script Ypkis Linux - Newbie 5 10-12-2003 07:35 AM


All times are GMT -5. The time now is 12:57 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration