Register a domain and help support LQ
Go Back > Forums > Other *NIX Forums > Other *NIX
User Name
Other *NIX This forum is for the discussion of any UNIX platform that does not have its own forum. Examples would include HP-UX, IRIX, Darwin, Tru64 and OS X.


  Search this Thread
Old 03-10-2010, 10:35 PM   #1
Registered: Jul 2009
Posts: 41

Rep: Reputation: 15
How can I run a command on another shell without changing the current shell?

Hi there, I have a problem:

My current shell is: /bin/bash, I just want to run a set of commands on /bin/sh shell without changing the current shell or put the set of commands into a script file.

# sh (echo "abc"; echo "cde")

Thanks for your help.
Old 03-10-2010, 11:58 PM   #2
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 5&6 CentOS 5, 6 & 7
Posts: 572

Rep: Reputation: 56
sh -c "/bin/echo Hello; echo Bye"
Old 04-05-2010, 10:58 AM   #3
Registered: Jul 2009
Posts: 41

Original Poster
Rep: Reputation: 15
Old 04-05-2010, 01:19 PM   #4
LQ Newbie
Registered: Nov 2009
Posts: 20

Rep: Reputation: 0
blacky_5251 that is definitely correct. But there is one thing here that is missing that is really bad for all of the people that are starting to use linux and just find this answer. They don't understand why that works. To make a long story short the linux community is just coming down to a bunch of people that do things only because they find the exact answer on the internet and never understand anything about it. Quanba, to run a command in another shell you need to specific the shell that you want to run in and follow it with the command that you are going to run. The "-c" argument means that there are commands to run in this shell. This is the same for all shells.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
what is the command to find the current shell type babu198649 Linux - Newbie 5 11-11-2008 03:44 PM
How to run root privileged Linux command as normal user via shell shell tcegrid Linux - Newbie 1 06-23-2008 04:38 PM
command to temporary change current shell. hocheetiong Linux - Newbie 1 04-24-2008 02:07 PM
Changing my keyboard layout (language) globally by command (shell) Santorres Linux - Newbie 1 05-17-2004 03:04 PM
how to run shell command in java? u4u Linux - General 3 03-02-2004 10:08 AM

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration