MartyM wrote: Hi All I'm new to boards.ie and posted this question in the "Programming" forum last night, having just found this forum, perhaps this is where I should have posted... 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? The commands must be in this order because the /vobs/... dir is not accessible without the clearcase view being set. btw....I use tcsh Any help with this would be great! Cheers!
PaschalNee wrote: My guess would be that cleartool is a shell script that exports a variable that your source command reads. Type "type cleartool" and open the file it references in vi to see what it is doing. It could be that the cleartool script does not work in tcsh i.e. is bash specific.
echo "source /vobs/mydir" | cleartool setview myview
source /vobs/mydir blah blah blah exit
cleartool setview myview < commands.txt
PaschalNee wrote: OK based on that I'd tryecho "source /vobs/mydir" | cleartool setview myview or create a text file with your commands e.g.source /vobs/mydir blah blah blah exit and docleartool setview myview < commands.txt
PaschalNee wrote: >the normal command prompt returned in both cases after about 3 seconds Sounds like it worked to me - what were you expecting to happen
expect -c "spawn cleartool setview myview; send \"source /vobs/mydir/\";interact "
PaschalNee wrote: Expect might do the trickexpect -c "spawn cleartool setview myview; send \"source /vobs/mydir/\";interact " You can move the expect script into a file to get around needing to escape the double quotes.
#!/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