LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Run part of a bash script from within another (http://www.linuxquestions.org/questions/linux-newbie-8/run-part-of-a-bash-script-from-within-another-805979/)

tbj01 05-04-2010 09:03 PM

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 :)

catkin 05-05-2010 01:52 AM

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.

A.Thyssen 05-05-2010 06:29 PM

Quote:

Originally Posted by tbj01 (Post 3957557)
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.


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