Executing a command in subshell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Executing a command in subshell
# 1  
Old 10-30-2013
Executing a command in subshell

Hi All,

I am trying to create a shell script which runs on my linux machine.

The requirement is so that,
Code:
ade createview xyz -> this steps creates a view
ade useview xyz -> we are entering inside the view
ade begintrans -> begin a transaction

My script has following code :

lets say my view name is xyz

Code:
n=`ade createview xyz`
n=`ade useview xyz`
n=`ade begintrans`

When I run these commands separately in my system, everything works fine but while trying to run these commands via shell script, the
ade createview xyz

command is successful but it stucks at the second command. I read something about subshells and pipelines, and since the 3rd command must run after the 2nd command I tried the parenthesis and |, it doesnt work.

FYI, the second command changes the directory structure, inside from which only 3rd command can be run.

Please suggest that how do I make sure that the 2nd command changes the directory structure and in side which only 3rd command is run..

Also is there any way user can also see the output these commands prints while I run them separately directly on terminal.

Thanks in adv..
Dish

Last edited by Scott; 10-31-2013 at 08:47 AM.. Reason: Please use code tags
# 2  
Old 10-30-2013
Not clear. Post the relevant portion of your script, and OS & shell versions.
# 3  
Old 10-31-2013
Oracle

Code:
# Function Declaration Start

echo -n "Enter Series Name : "
read series
echo -n "Bug Number : "
read bugNumber

n=`ade createview xyz -latest -series $series
n=`ade useview xyz`   ----> here is where my script is getting stuck
n=`ade begintrans bug\-$bugNumber`  ----> this command should run only after we are inside the view, which happens by running useview command successfully.


#EOF

This is my script.
These command are ADE commands. Ref # http://docs.oracle.com/cd/A60725_05/...er/iw04c03.htm

I do not want you to go into much details but all I want to do is, retain the path which is achieved by useview command and then continue supplying the begintrans command. Apparently useview command internally starts a subshell, so my doubt is how do i run following command in the subshell created by previous command and retain the paths.

Hope I am clear.

Please let me know if I can clarify more.

Thanks,
Dish

Last edited by Franklin52; 10-31-2013 at 07:44 AM.. Reason: Please use code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help executing command with options

Hi, I have this command in a shell script and I can get it to echo ok, but when I try to execute the command I get a "file not found" error. Which is strange because, if I copy and paste the same command at the cli it works ok. What am I doing wrong please? (16 Replies)
Discussion started by: bbbngowc
16 Replies

2. Solaris

Role not executing command

Hello Guys, I am studying RBAC. So I create a role called sysadm and gave it the "shutdown" profile. Now when I switch to that role, and execute the shutdown command $ shutdown -y -g0 -i5 The system responds with : shutdown: not found Can anyone help me with this please?... (1 Reply)
Discussion started by: cjashu
1 Replies

3. UNIX for Dummies Questions & Answers

executing a command using ssh

Hi All, I am trying to execute a command using ssh as below. ssh user123@servername "which ctmcontb" It is gving the error as below no ctmcontb in /usr/bin /usr/sbin /opt/sysadm/bin Not sure from where the PATH is getting picked up. But When I login direclty to the server I am... (5 Replies)
Discussion started by: anilreddy103
5 Replies

4. Shell Programming and Scripting

Which filesystem a command is executing from?

Hi. We can have one or more agents of a particular type running on our AIX and Solaris servers. As these agents have usually been installed into their own filesystems, I need to capture the filesystem names for auditing purposes. I've had a search through the forums can see something that fits the... (16 Replies)
Discussion started by: smoosmoo
16 Replies

5. Shell Programming and Scripting

cd command not executing in if else loop

Hi, I am executing below script s1=`pwd` s2=/space if then echo "done" else echo "mistake" cd /tmp fi I am not able to migrate to /tmp directory if the condition is not true.However mistake is being printed.Means cd command is not working here.All other commands except cd are... (3 Replies)
Discussion started by: d8011
3 Replies

6. AIX

Command executing to be in the background !

Guys I'm working to make in AIX script and I have some commands need to be excited by that script Like the below commands ... startsrc -s sshd I want that executing to be in the background of the system I do not like to see the out put of that (3 Replies)
Discussion started by: Mr.AIX
3 Replies

7. Shell Programming and Scripting

Prepare command before executing

Hi, Couldnt find the right string" to search for a similar question..so dont know if this has been answered yet...problem is that I want to prepare a command with the requisite parameters passed as a string before executing it...eg: the ls command .. I can pass "-l", "-t" as parameters and... (12 Replies)
Discussion started by: harman_6
12 Replies

8. UNIX for Dummies Questions & Answers

Doing a capture while another command is executing?

Basically what i'm trying to do is execute an update command and at the same time have the system do a TCPdump to file for that update traffic. So I would like to connect the two commands so that the tcpdump terminates automatically when the update finishes/fails/whatever. Right now I have... (0 Replies)
Discussion started by: MrEddy
0 Replies

9. Shell Programming and Scripting

executing command from subdirectories

Hello, I've been trying to run 'ls -1R | wc -l' inside of sub directories to in order to determine how big each folder is. find . -maxdepth 1 -type d | while read folder do cd "$folder" && echo "$folder has $(ls -1R | wc -l) files" && cd .. done or for... (3 Replies)
Discussion started by: NoobProgrammer
3 Replies

10. Shell Programming and Scripting

Executing a command at startup

Hey all, How do I execute a file at startup automatically. From what I've read is that I need to put it into my .bashrc file. I'm not sure where to go from there. Can I just type commands into that and they'll run next time I restart my server? Right now I have added these lines: cd... (2 Replies)
Discussion started by: NathanWarden
2 Replies
Login or Register to Ask a Question