LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Other *NIX
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 03-10-2010, 09:35 PM   #1
quanba
Member
 
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.

e.g:
# sh (echo "abc"; echo "cde")

Thanks for your help.
 
Old 03-10-2010, 10:58 PM   #2
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 4&5, Fedora 10, CentOS 5.4, IPCop
Posts: 569

Rep: Reputation: 55
Code:
sh -c "/bin/echo Hello; echo Bye"
 
Old 04-05-2010, 09:58 AM   #3
quanba
Member
 
Registered: Jul 2009
Posts: 41

Original Poster
Rep: Reputation: 15
thanks
 
Old 04-05-2010, 12:19 PM   #4
gumaheru
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.
 
  


Reply


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 02:44 PM
How to run root privileged Linux command as normal user via shell shell tcegrid Linux - Newbie 1 06-23-2008 03:38 PM
command to temporary change current shell. hocheetiong Linux - Newbie 1 04-24-2008 01:07 PM
Changing my keyboard layout (language) globally by command (shell) Santorres Linux - Newbie 1 05-17-2004 02:04 PM
how to run shell command in java? u4u Linux - General 3 03-02-2004 09:08 AM


All times are GMT -5. The time now is 03:42 PM.

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