0

I have a perl script which is working fine, but then I wanted to add some shell script in it. I tried to google but I don't know the exact word. Is it embedded programming? So this is what I know.

We can write assembly code in a C file like this:

*****
C - code
int a=10;
char *p;
asm {       //here is the secondary or embedded language (assembly code)
assembly code...
ldaa 1;
push;
}

back to C...
print( "this works");

I just want to do something along these lines, but with perl as the main language and shell script being the secondary or embedded language.

Thank you everyone

1

1 Answer 1

1

Is this what you are looking for?

$exec_string = <<EXEC;
echo this is my shell script
ls > tmp1
ls > tmp2
EXEC

system($exec_string)

EXEC can be substituted by any word (e.g. SHELL, SCRIPT, whatever).

Sign up to request clarification or add additional context in comments.

9 Comments

and $exec_string is just another perl variable here?
Yes, you can use it like any other scalar.
and one last thing...is this called embedded shell script or somethins else?
@sush basically you are just creating a multi-line string, storing it in a variable and executing it. You can do whatever you want with this string - e.g. you can print it instead of executing it.
yes but i just want to know what the process is called...so people understand me when I open my mouth
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.