help with shell script

I need to do something like this:


do shell script "openssl sha1
a2d3b4c5a2d3b4c5fa2d3b4c5fa...5fa2d3b4c5fa2d3b4c5fa2d3b4c5fa2d3b4c5ff

openssl sha1 expects a filepath. If not, just a return, it will process standard input until ^D.

As above doesn’t work.
Now what?

set mydata to "rtyeylohyvuftydyrerussy"

do shell script "echo \"" & mydata & "\"| openssl sha1"

Good grief!

Hello there.

Try this in a terminal window:

echo |openssl sha1

What is going on here, is that the echo command (man echo sends a newline through the |.

So hopefully this will work for you:


do shell script "echo |openssl sha1
a2d3b4c5a2d3b4c5fa2d3b4c5fa...5fa2d3b4c5fa2d3b4c5fa2d3b4c5fa2d3b4c5ff"

And you do use my applet/droplet for opening terminal windows in tabs don’t you? :slight_smile:

A | is named a pipe and connects stdout of the left command to the stdin of the right command of the pipe.

As you have may have noticed in some/many of my example code I use:

do shell script "/bin/echo -n hello world"

That is not the shell’s built in echo command which has a few options more than the buil-in version. With the option -n you tell echo not to print a traling newline.

Because openssl likes to read from stdin, which is not that uncommond for command line utilities, you should use

set mydata to "rtyeylohyvuftydyrerussy"
do shell script "/bin/echo -n " & quoted form of mydata & "| openssl sha1" 

I know what a pipe is. And stdin. And stdout. What I have trouble is with right and left. :lol:

I hate the <expletive deleted> terminal!

Well, It is a great place for figuring out how your “do shell scripts” works! :slight_smile:

And we all have to resort to that sooner or later. you can just drop a folder on my droplet to go to that folder! :slight_smile:

if you move arrow up you should go to the last command, history |more gives you an overview of previously entered commands.

It is not so dreaded, once you get used to it.