Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: How to call Linux command sequentially

by JavaFan (Canon)
on Sep 13, 2011 at 09:40 UTC ( [id://925660]=note: print w/replies, xml ) Need Help??


in reply to How to call Linux command sequentially

What's the problem here? In the shell, you can just type the first command, and type the second before the first is finished. It'll be executed right after the first is finished.
  • Comment on Re: How to call Linux command sequentially

Replies are listed 'Best First'.
Re^2: How to call Linux command sequentially
by mv.ashwin@gmail.com (Novice) on Sep 13, 2011 at 10:05 UTC
    OK. Now i do not have any error messages. 1. Using first command as shown above i want to create an environment. I was able to create it from my .pl script its is perfectly fine. 2. Once the environment is created the perl script idles it will not run the next line untill i exit form the environment. 3. I want to run the commands in the environment which was created by first command. I tried using cojoined command or individually one after another. but the perl idles aftre finishing the first command it wont run the rest of the lines untill i exit from the created environment.

      You seem to have a different opinion on what "sequentially" means. The meaning I am aware of for "sequentially" means "one after another", which means that no two commands may be running at the same time.

      You seem to want to run two commands at the same time - first the command that sets up the environment and starts a new shell, and in that shell run another command.

      The solution of piping in the commands into that shell or the solution of retrieving the environment settings from that shell are both approaches that can help here.

        Good catch Corion.
        So what you want to do is open a shell with your tool setup script and in that shell enter your the second command. Something like the following might do it for you
        #! /usr/bin/perl use strict; my $tool_shell = '/bin/toolsetup.pl -p coi -config d4 -t all -ov /nfs/ +home/akmvx/test -n toptest'; open (my $ts , "|-" , $tool_shell) || die "Failed to open tool setup:\n\tCommand:\t$tool_shell\n\tErro +r:\t$!\n"; print $ts "touch file1\n"; print $ts "$exit_command";
        print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."
        Sorry if the "sequentially" word have diverted you. You are correct i want the second command to be run in the environment created by first command. Initially i will be in home dir & shell:/usr/bin/tcsh when i run the first command a envirinment will be created in "/nfs/home/akmvx/test" which was the input to first command "-ov /nfs/home/akmvx/test" same shell. There the second command should be executed. Please help.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://925660]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-04-19 03:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found