LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Require Linux/Perl equivalent command for windows Command (https://www.linuxquestions.org/questions/programming-9/require-linux-perl-equivalent-command-for-windows-command-354554/)

alix123 08-18-2005 09:58 AM

Require Linux/Perl equivalent command for windows Command
 
Hello All

I am looking for a equivalent command in linux for the following perl command.

#code in windows
#test1.pl/test1.exe Code is as follows
system("start c:\scripts\sscript.exe");

#some more code

#end test1.pl

the above perl command in test1.pl will start a new command prompt and start executing the sscriptexe. Morover the test1.pl /test1.exe will go also paralley start excuing the some more code.


The Equivalent of the above code in linux is

#test1.pl in linux
system("perl /root/scripts/script.pl");
#some more code
#test1.pl ends in linux

where as in the linux code as shown above from the shell if go to "/root/scripts" and type the commadn perl test1.pl

it excutes and also start executing it on the same shell.

IS there any similar way from perl to start a script everytime in a new shell. morover the excuting/calling shell should also go on paralley.

I tried
system("xterm -e perl/root/scripts/scirpt.pl") in this case it starts xterms but without executing it exits morover the executing shell looses and cannot go paralley since the current shell started the xterm. it will not get back the control until the started xterm is exited.


i Will be glad if somebody can answer the question.

PenguinPwrdBox 08-18-2005 10:20 AM

Are you attempting to use this to spawn a new X-window to run the command?
Or are you simply trying to run the script within it's own process space (forking)?

alix123 08-18-2005 12:49 PM

yes Iam attempting to use this to spawn everytime a new X-window to run the command?
 
yes Iam attempting to use this to spawn everytime a new X-window to run the command? at the same time the calling window should also be able to proceed .

the objective is to :-- get the equivalent of :-system("start c:\scripts\script.exe"). in windows to linux

since we dont have exe's in linux so i want system("perl /root/scripts/scirpt.pl"); to spawn in a new window and should excute. at the same time the current window should be able proccess as well as the spawned window to their own commad excute its own command.

PenguinPwrdBox 08-18-2005 01:20 PM

You should not use system, as the calling window will wait on an exit code from the script that you are calling before continuing.

Try using backticks ( ` ) to run the command:

Code:

`xterm /path/to/script`;
See if that will work. You should be able to do what it is you are attempting, without much hassle. If you are unable to get the command to run after the terminal is launched - check the documentation for that terminal to find the syntax of the command. I am not familiar with xterm, so I can't help there....

alix123 08-18-2005 01:34 PM

since i want to call/run another script from a perl script
 
Since I want to call/ run a perl script(which should be excuted on a different shell) from a perl script . so i will have to use system (this is perl command for excuting commands on shell in linux and command prompt on linux)

frandalla 08-18-2005 03:32 PM

hey buddy!
try this:

system("xterm -e perl/root/scripts/scirpt.pl &")

this & thing will make the process run on background allowing the rest of the code to go on! =)

PenguinPwrdBox 08-18-2005 06:13 PM

It's pretty obvious you don't know perl.

There are multiple ways to call an external command from a perl script:

system()
exec()
and using backticks ( ` )

are among the most popular.

Since you are obviously so much more of an authority, and completely unwilling to accept suggestions from others - I have no doubt that you will figure out how to do it on your own.

For future reference - the people in this forum are trying to help you - so it would serve you well to not be such a know-it-all schmuck.

chrism01 08-19-2005 02:23 AM

If you just want to start another prog and not wait for it to complete, you do not need a new terminal/window, just something like this:

system("nohup /path/to/script.pl &");

You should have

#!/usr/bin/perl -w

as the first line in the script, so you don't have to specify perl as part of the cmd line.


All times are GMT -5. The time now is 09:06 PM.