Run a command in a special shell

Hi there,
Imagine we have to run a command in python shell from a perl script.

1  #!/usr/bin/perl
2  use strict;
3  my @con;
4  @con = `python`;
5  #?????print `print 'salaam'`;????

What's suitable situation for fifth line?
Thanks in advance.

I'd rather write it this way

1  #!/usr/bin/perl
2  use strict;
3  my $python = `which python`;
4  my $return;
5  $return = `$python -c print 'salaam'`;

Thanks pludi, but indeed I need to run command in the shell of python or other shells, is it possible?

My suggestion would be to put the commands you need into a file of their own (either static or generated at runtime), and call the shell with that file as a parameter (or make it executable and run it like any other program)

If you want to interact with the shell, OTOH, you'll probably need something like the Expect module. Bidirectional communication with a process is possible in Perl, but ugly, and definitely not beginner-friendly.

Pludi Tnx a lot :rolleyes: