Re: Shell Script on a string
Re: Shell Script on a string
- Subject: Re: Shell Script on a string
- From: John Delacour <email@hidden>
- Date: Sat, 16 Nov 2002 09:26:56 +0000
- Mac-eudora-version: 5.3a9
At 10:07 pm -0500 15/11/02, Hudson Barton wrote:
I have a shell script as follows:
"set this_result to do shell script ("/usr/bin/openssl sha1 " &
this_File) as string"
I need to know how to run the same routine on a text segment rather
than on a file. Obviously, I'm inexperienced in working with
Terminal-like commands.
1.
if openssl is in /usr/bin/, as it is, you don't need to give the full
path to the executable and you can be in any directory. If you have
an executable in a location that is _not_ in the path, then you
execute it by prefixing ./ to the name
/usr/local/apache2/bin/./apachectl start
or
cd /usr/local/apache2/bin/ ; ./apachectl start
2.
You can read what is possible in openssl by typing 'man openssl' in
the terminal
3.
You would run into problems if you used a string rather than a file
because of encoding questions, so it's best to use files. The
routine below shows how you might encode "abcde" in base64 by writing
the string to a temp file, encoding it into a second temp file and
reading this.
set s to "abcde"
set fin to "/private/tmp/in.txt"
set fout to "/private/tmp/out.txt"
set finmac to POSIX file fin
set foutmac to POSIX file fout
open for access finmac with write permission
set eof finmac to 0
write s to finmac
close access finmac
read finmac
do shell script "openssl enc -base64 -in " & fin & " -out " & fout
set encoded to read foutmac
-- JD
_______________________________________________
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.