Results 1 to 7 of 7
Hello,
I have never made a bash script in my life, so i need some help.
I want a script thats taking the output of an command and use it ...
- 07-23-2008 #1Just Joined!
- Join Date
- May 2008
- Posts
- 7
Get output of a command
Hello,
I have never made a bash script in my life, so i need some help.
I want a script thats taking the output of an command and use it in a other command.
somthing like:
$command1 = 'uptime'
$command2 = 'customcommand'
and then the it will be put thogeter and run
$command2 $command1.
Do you understand?
- 07-23-2008 #2
Use pipe command .
pipe command redirects output command-1 as an input for command-2
Example:
output of ls command is the input for more command.Code:$ls | more
For more click here
Pipeline (Unix) - Wikipedia, the free encyclopedia- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
- 07-23-2008 #3
If you want to take the output of one command and make that the input of another command, and these two commands have been assigned to variables, do this:
Code:command1='uptime' command2='customcommand' $(command1) | $(command2)
--
Bill
Old age and treachery will overcome youth and skill.
- 07-23-2008 #4Just Joined!
- Join Date
- May 2008
- Posts
- 7
Okay, think thats what im after, but the last command must be in "" When its outputted after the first, how do i do that?
- 07-23-2008 #5Are you talking about the solution offered by Lakshmipathi, or the one offered by wje_lf?Okay, think thats what im after
I have no idea what you're asking here. Could you illustrate with an example or something?the last command must be in "" When its outputted after the first, how do i do that?--
Bill
Old age and treachery will overcome youth and skill.
- 07-23-2008 #6Just Joined!
- Join Date
- May 2008
- Posts
- 7
Your example.
Okay, im not god to explain but ill try,
Code:command1='uptime' command2='customcommand' $(command1) | $(command2) the last output of everything should be: comstomcommand [options to this command] "uptime" or #comstomcommand -s "22:47:07 up 2:21"
- 07-23-2008 #7Just Joined!
- Join Date
- May 2008
- Posts
- 7
I got it working
Thanks for the guide lines!
The code for getting command2 after command1 in qoutes:
Code:command1='uptime' command2='customcommand' $command2 "`$command1`"


Reply With Quote