kel1
October 16, 2013, 9:49pm
#1
Hi,
I think I did this before. How do you make the result from the shell call on the same line. e.g.
do shell script "(echo hello; echo goodbye)"
→ “hello
goodbye”
Instead of the results being on separate lines, have them on the same line.
thanks,
kel
McUsrII
October 16, 2013, 11:03pm
#2
Hello.
echo -n shouldn’t put out a new line after it has output its argument.
kel1
October 16, 2013, 11:12pm
#3
Hi McUsr,
do shell script "(echo -n hello; echo goodbye)"
didn’t work. But I was thinking of a more generic way. If you didn’t think of it by now it probably doesn’t exist, I think.
That’s ok. At least I have the two outputs.
Thanks anyway,
kel
It’s a known bug in the built-in echo command, you need to use the echo in /bin but that version doesn’t support the -e option.
do shell script "(/bin/echo -n hello; /bin/echo goodbye)"
kel1
October 16, 2013, 11:18pm
#5
What I was thinking was that you make all the shell script calls at the same time as much as possible. Sometimes you can’t do that because one call might need data from another call. Then ou don’t need to make as much shell calls.
Hi. Quotes and \c.
do shell script "echo 'hello \\c'; echo 'goodbye'"
kel1
October 16, 2013, 11:24pm
#7
Hi DJ Bazzie Wazzie,
It worked! /bin … How do you guys get these things?
Thanks a lot!
kel
kel1
October 16, 2013, 11:29pm
#8
What does the c\ stand for?
Edited: and there’s a space in between.
kel1
October 16, 2013, 11:32pm
#9
I wonder if it will work with parallel processes.
Because I asked myself the same question when I came from Mac OS to Mac OS X and using do shell scripts. Then reading man pages to find solutions. I also had experience in Bash before I first used Mac OS X did. So the key is that we’ve all been there but some a decade ago, others today and some tomorrow
coalescing the above notes, and testing:
Two methods:
(1) \c works, but only with /bin/echo
do shell script "/bin/echo 'hello \\c'; echo 'goodbye'"
(2) -n works, with either echo
do shell script "echo -n 'hello '; echo 'goodbye'"
do shell script "/bin/echo -n 'hello '; echo 'goodbye'"
[Tiger, AS 1.10.7]
kel1
October 18, 2013, 8:27am
#12
Hi mhfadams,
Thanks for the great summary. One thing this one didn’t work for me:
do shell script "echo -n 'hello '; echo 'goodbye'"
Thanks,
kel
Model: MBP
AppleScript: AS 2.2.4
Browser: Safari 536.28.10
Operating System: Mac OS X (10.8)
This is known in the built-in version of echo in bash, like I said before. You can either use the \c at the end of string (for built-in echo command) or use the option -n for the echo command in your bin folder.
Thanks – now I understand: built-in echo vs. separate echo command.
I missed that distinction in your prev. post. Sorry.
That explains the ‘\c’ method compatibility,
but why does the ‘-n’ method work for me (built-in echo) but not for Kel1 ?
If it’s the built in version of bash that is working it could be that you’re using a different (fixed) version of bash.
do shell script "echo $BASH_VERSION"
My bash returns 3.2.48(1)-release , it’s shipped with the latest version of Snow Leopard.
kel1
October 18, 2013, 4:00pm
#16
I see now. The bug is in the bash built-in ‘echo’. Keeping the output on the same line needs the /bin/echo. Both methods don’'t work without the bin.
Thanks,
kel