Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Simple shell script to execute 2 unix cmds

  • 26-04-2007 9:13pm
    #1
    Registered Users, Registered Users 2 Posts: 264 ✭✭


    Hi All

    I'm having problems creating a simple shell script to execute 2 unix commands.

    Basically, the commands are:

    > cleartool setview myview
    > source /vobs/mydir/...

    Setting the clearcase view is causing the problem, this command seems to launch a subshell (i.e. the SHLVL environment variable is incremented), so the 2nd command does not get executed until I exit the subshell.

    How do I get the 2nd command to execute in the subshell?

    btw....I use tcsh

    Any help with this would be great!

    Cheers!


Comments

  • Registered Users, Registered Users 2 Posts: 6,334 ✭✭✭OfflerCrocGod


    Change the ordering of the commands?


  • Registered Users, Registered Users 2 Posts: 264 ✭✭MartyM


    I cant, in order to access the /vobs... directories I must have my clearcase view set...


  • Registered Users, Registered Users 2 Posts: 6,334 ✭✭✭OfflerCrocGod


    I've never seen those commands before so I'm guessing here but can you run it in the background ( & ) or maybe there is a way to pipe the second command into the new shell cmd1 < cmd2 I suppose ; wont work as that's the same thing as putting the two commands on different lines.


  • Registered Users, Registered Users 2 Posts: 264 ✭✭MartyM


    Thanks for the suggestions!....yeah, I tried piping the commands but for some reason it only executed one of them...the 2nd I think. Was doing this at work, so dont remember the exact details....i've tried so many things at this stage...


  • Registered Users, Registered Users 2 Posts: 6,570 ✭✭✭daymobrew


    I remember this dilemma when I used to work with ClearCase, when it was still Rational and had some corny marketing slogan.

    I searched the knowledge base on ibm.com and found one article that suggested using startview instead of setview and one that uses the '-exec' parameter.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 264 ✭✭MartyM


    daymobrew wrote:
    I remember this dilemma when I used to work with ClearCase, when it was still Rational and had some corny marketing slogan.

    I searched the knowledge base on ibm.com and found one article that suggested using startview instead of setview and one that uses the '-exec' parameter.


    Thanks Daymobrew and everyone else!!!

    Ideally I wanted to remain in the clearcase envornment and have the equivalent of the following from the command line:

    > cleartool setview myview
    [myview] > source /vobs/setup

    [myview] > Then continue working
    [myview] > within the clearcase environment
    [myview] > and within the subshell spawned by the cleartool command


    However, I found this workaround on the same site as you have highlighted:

    http://www-1.ibm.com/support/docview.wss?rs=984&context=SSSH27&dc=DB520&uid=swg21119859&loc=en_US&cs=UTF-8&lang=en&rss=ct984rational

    The following script allows me to set my view, source the vob and execute a
    command within the clearcase environment.

    The downside is that I dont remain in the clearcase environment.

    The upside is that I dont have to "enter" the clearcase environment when using the alias! :)

    #!/bin/tcsh
    
    # This script allows the user to run the 'extractinfo' command from the vobs
    # without having to set their view or source /vobs/setup manually.
    
    # The script is executed with the following command:
    #
    #	cleartool setview -exec ~<user>/bin/source_extractinfo.sh myview
    # 
    # OR with the alias 'lminfo' defined in ~<user>/.aliases
    
    # Source vobs so that the extractinfo utility can be used to extract LM information
    source /vobs/setup
    
    # Prompt the user to enter the location and name of the LM
    echo "Enter: /path/to/loadmodule"
    
    # Read user input from stdin
    set LM = $<
    
    echo "Performing 'extractinfo' on the following LM: $LM..."
    
    # Run the 'extractinfo' command to extract the LM info
    extractinfo $LM
    


Advertisement