• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting result from shell scp command
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting result from shell scp command


  • Subject: Re: Getting result from shell scp command
  • From: Graff <email@hidden>
  • Date: Tue, 22 Mar 2005 08:44:24 -0500

If you look in the Apple Technote for the "do shell script" command it mentions how to do this:

<http://developer.apple.com/technotes/tn2002/tn2065.html#TNTAG5>

"Q: My script will produce output over a long time. How do I read the results as they come in?

A: Again, the short answer is that you don't – do shell script will not return until the command is done. What you can do, however, is to put the command into the background (see the next question), send its output to a file, and then read the file as it fills up."

For example:

----
do shell script "/usr/bin/scp email@hidden:~/thefile ~/thefile > ~/scplog.txt 2>&1 &"


set i to 0
set isDone to false
repeat while not isDone
set i to i + 1
set theCount to do shell script "/usr/bin/tail -n 5 ~/scplog.txt | /usr/bin/grep -c '100%' ~/scplog.txt"
if (theCount as integer) > 0 then set isDone to true
if i > 1000 then set isDone to true
delay 1
end repeat


if i > 1000 then
	display dialog "Transfer Timed Out"
else
	display dialog "Transfer Complete"
end if

set scpResult to do shell script "/usr/bin/tail -n 1 ~/scplog.txt
----

I haven't tested this because I don't have another machine to scp to but it should give you an idea of how it works. I used the tail command before the grep command to cut down on large greps, you are really only concerned with the last few lines anyways.

- Ken

On Mar 21, 2005, at 10:35 PM, Gnarlodious wrote:

When I run an scp command in Terminal I get text like:

:~/Sites/Gnarlodious/Blog/  2005-03.html  100%  537   232.3KB/s   00:00

How would I get this result in Applescript?

I tried the trick with putting  “2>&1” at the end of the command but it
didn’t work.

_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Getting result from shell scp command
      • From: Gnarlodious <email@hidden>
References: 
 >Getting result from shell scp command (From: Gnarlodious <email@hidden>)

  • Prev by Date: Re: Illustrator CS Text Frames
  • Next by Date: Re: Getting result from shell scp command
  • Previous by thread: Getting result from shell scp command
  • Next by thread: Re: Getting result from shell scp command
  • Index(es):
    • Date
    • Thread