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 05-04-2010, 09:03 PM   #1
tbj01
LQ Newbie
 
Registered: May 2010
Posts: 1

Rep: Reputation: 0
Run part of a bash script from within another


I have two scripts, one of which is very long (around 11000 lines), and i need to run this two lines at a time within the other script. Is there any way to do this?

Any help is greatly appreciated
 
Old 05-05-2010, 01:52 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,551
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
There are ways to get two lines from a file and execute them as commands but I do not know of a way to get a script to execute two lines and stop until told to proceed by another process.
 
Old 05-05-2010, 06:29 PM   #3
A.Thyssen
Member
 
Registered: May 2006
Location: Brisbane, Australia
Posts: 119

Rep: Reputation: 32
Quote:
Originally Posted by tbj01 View Post
I have two scripts, one of which is very long (around 11000 lines), and i need to run this two lines at a time within the other script. Is there any way to do this?

Any help is greatly appreciated
As mentioned the only real way is for the other script to extract the lines and feed it piecemeal to a bash interpreter.

However doing this really depends on how complex the source script is. For example if the source script contains large 'loops' or other 'code blocks' then bash will not execute them until the code block is complete. Better if the script had some sort of marker (special comments) or other delimiters to separate the individual sections of code to be executed.

I have does this myself, but extracting blocks of code from a HTML file, so that the output it generates (images) can also appear on the same page, guaranteeing that the code generates what is displayed. It worked very well, and pre-dates the advent of Wiki's.

ASIDE: The shell code was stored in HTML <CODE EXECUTE ...> ... </CODE> constructs. Note that 'EXECUTE' is not a standard HTML tag, so should be ignored by browsers. You can see the results on the page..
http://www.imagemagick.org/Usage/basics/#example
If you look at the page source you will see the code blocks.
 
  


Reply

Tags
bash scripting


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
[SOLVED] bash script is reprinting part of a field from an awk statement ?? SharpyWarpy Linux - General 13 04-22-2010 03:58 AM
Small part of Bash Script that I would like to explain it to me jefn Programming 10 04-11-2009 04:09 AM
remove part of string in bash script crewblunts Programming 2 03-16-2006 05:54 PM
Simple bash script help, grabbing part of a string colabus Linux - Newbie 3 04-25-2005 09:42 AM
Getting the first part of a filename in a BASH script trevelluk Programming 3 02-15-2005 01:06 AM


All times are GMT -5. The time now is 09:03 AM.

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