Re: Pipes
Re: Pipes
- Subject: Re: Pipes
- From: Stevan Reese <email@hidden>
- Date: Sat, 10 Jan 2004 23:50:24 -0800
If I'm not mistaken the default shell used in "do shell script" is
/bin/sh.
To debug your shell script commands in the shell that they will be run
in, type /bin/sh <return> in the terminal then test your commands.
You will have to watch for "\" and remove them where they are used to
escape a character in Applescript. This can get confusing because some
characters need to be escaped in the shell and Applescript so you may
have 2 or 3 all together in the apple script and only need one in the
shell script version.
stevan
On Jan 10, 2004, at 10:39 PM, Marc K. Myers wrote:
These are being used in shell scripts that I use to find matching
processes in "ps" listings and matching files in "ls" listings. The
first is "cprc" ("see processes") and the second is "cfle" ("see
files"). Each is invoked with a single argument which is the string
to be matched in the listing.
There's probably a way to debug what's going on inside a shell script
but I haven't figured it out yet.
Marc [01/11/04 1:24:25 AM]
Date: Sun Jan 11, 2004 12:56:05 AM America/Detroit
To: "Marc K. Myers" <email@hidden>
Cc: email@hidden
Subject: Re: Pipes
First of all, "$1" resolves to a variable named 1. Doing [2] gives
me a listing of everything in the working directory, to find out why
I checked what $1 was set to by doing:
echo "$1"
It turned out that the variable $1 was set to a linefeed and was thus
matching every line from the ls command.
If you want to search for a literal $1 you should do this:
ls -la | grep -i '\$1'
You need the \ before the $ because a $ is a metacharacter that
represents the end of the line in a regular expression and so the \
escapes that metacharacter and makes it into a normal dollar sign.
So basically things are most likely acting screwy because you are
running into some murky waters where things are a bit undefined.
What is it that you are trying to grep here? If you explain what
pattern you are trying to match then we can see what is best to use.
- Ken
On Jan 10, 2004, at 11:44 PM, Marc K. Myers wrote:
Could someone tell me why this works:
[1] ps -acx | grep -i "$1"
and this doesn't?
[2] ls -la | grep -i "$1"
This *will* work:
[3] ls -la | grep -i "${1}"
and this will work
[4] ps -acx | grep -i "${1}"
but I can't figure out why [2] won't.
Marc [01/10/04 11:43:56 PM]
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
References: | |
| >Re: Pipes (From: "Marc K. Myers" <email@hidden>) |