Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Apr 5th, 2005, 9:38 AM   #1
trufla
Newbie
 
Join Date: Apr 2005
Posts: 6
Rep Power: 0 trufla is on a distinguished road
Piping in a script

Hello all!

I was writing a simple script to search text files for data using grep and I decided to have a go at writing a script that piped unix commands to grep too. I am having problems though.

I think the problem is in the storing of user input in a variable.

For example:- If I wanted to store

who|grep ^l

in a variable called $pipe

is the spacing of the command an issue when stored in variables or am I completely off the point?

This is my code:-

#!/bin/bash
#Filename: piping : Author: L.Pearce

function pipefunction
{
 $pipe
}

echo
echo
echo "Type command in full:"
echo "1. Type unix command you want to pipe to grep."
echo "2. Type the 'pipe' symbol and name of tool you are using."
echo "3. Type the metachars and criteria to search with here:"
         read pipe

#:::How can the command stored in that variable be run:::
#------------------------------------------------------------------------
#By calling the function "pipefunction"

             pipefunction
echo
echo
echo "The entries above match your search"
echo
echo

I get this error:-

./piping: line 8: who|grep: command not found

Cheers,


Trufla

Last edited by trufla; Apr 5th, 2005 at 9:41 AM.
trufla is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:23 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC