Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to grep the progress bar? #307

Closed
shoopdawoop opened this issue Nov 14, 2020 · 8 comments · Fixed by #625
Closed

How to grep the progress bar? #307

shoopdawoop opened this issue Nov 14, 2020 · 8 comments · Fixed by #625

Comments

@shoopdawoop
Copy link

A bit off topic perhaps, but I'll give it a shot:

I would like to run mas install in a shell script and report back when a download is finished and when it's successfully installed, but I cannot figure out how to do the former.

I thought I'd try a simple grep on the output, but only a mas install | grep "Installed" works (on the final output after the whole process is finished), while a mas install | grep "Installing" does not work.

It seems that the the output of the progress bar

################################################------------ 80.0% Installing

never gets piped to grep and only the final results ==> Downloading and ==> Installed actually get passed.
Throwing a | tee $somewhereelse in there does not work, either.

How can this be done?

@shoopdawoop
Copy link
Author

Nevermind, I found a way to work around this by temporarily sending installd to sleep until the download is finished.

I leave this open in case it is of interest to anyone as an actual feature request.

@phatblat
Copy link
Member

The clearLine called in PurchaseDownloadObserver is probably what's fouling up that output. It's intended to rewrite the current line for an updating progress bar but messes up the final stdout that gets ends up in a command pipe.

Detection of stdout redirection and/or a way to force simpler, more reliable output would help.

@philsherry
Copy link

Came looking for information about this while staring at Installing Xcode in the output of a script that I've written, which uses mas. I've been staring at it for quite some time now.

@rgoldberg
Copy link
Contributor

rgoldberg commented Sep 15, 2024

@shoopdawoop @philsherry
Is it really necessary to grep the progress indicators?

If so, will it suffice to output a separate persistent ==> Downloaded <app name> line after the refreshing download progress indicator line has disappeared, then a separate persistent ==> Installing <app name> line above the refreshing install progress indicator line? The persistent output would thus be something like:

==> Downloading App Name
==> Downloaded App Name
==> Installing App Name
==> Installed App Name

Why do you want to grep for any of this? I've run mas install from scripts, where I can see all of the persistent output & both of the progress indicators as they progress (though the progress indicator lines eventually disappear). Do you not want to see the progress indicators or other output? If so, why? Is your script hanging, so you don't know whether the download hasn't started, download has finished but the install hasn't begun, or the install has finished but the command is somehow stalled before the Installed output? Do the progress indicator lines not refresh, but instead take up a different line per refresh (or something else)?

How does "sending installd to sleep until the download is finished" help?

@rgoldberg rgoldberg changed the title Question: How to grep the progress bar How to grep the progress bar? Sep 15, 2024
@philsherry
Copy link

@rgoldberg It was 2 years ago but it was Xcode, which was notoriously large and cumbersome before they made it a bit more modular.

Seeing output such as you suggested would always be a good start, yes.

@rgoldberg
Copy link
Contributor

@philsherry Thanks for the info.

Are there any other problems that must be solved that aren't solved by the 2 extra persistent lines that I suggested? If I know additional problems, then I can devise & implement solutions to them.

I assume that grepping the progress indicators isn't actually necessary, it was just one proposed solution for which I've hopefully provided a better alternative.

Thanks for any more info you can provide.

@philsherry
Copy link

I can’t speak to the grepping issue, as that was OP so I’ll leave that for them.

The only other gripe I can think of right now is newer versions sometimes disappearing from the Dock upon install… but sometimes, not. But I imagine that’s outside the remit of this particular Issue.

More than happy to help with further questions, testing, and so on. It’s a great tool and it’s good to know someone is back on it.

@rgoldberg
Copy link
Contributor

rgoldberg commented Sep 15, 2024

@philsherry Thanks for the info.

I would assume that you meant disappearing from the Dock upon upgrade, not upon install, because how would it already be in the Dock if it weren't already installed? Or are you accidentally trying to install an app that was already installed?

Assuming you meant upgrade, have apps disappeared from the Dock when you've upgraded via the App Store GUI (instead of via mas upgrade)? If so, them it's likely an issue outside of mas (though mas could somehow disrupt MAS app metadata that then disrupts normal MAS usage). If not, then it's likely an mas problem.

If it seems like an mas problem to you, please open a new issue about it, and we can investigate it. It'll probably be a bit before we get to it, though, unless you or someone else pinpoint the problem, because of the large backlog of serious bugs & because it would require research into a whole new area (but it would be good to document as much as possible).

Thanks again.

@rgoldberg rgoldberg self-assigned this Oct 30, 2024
@rgoldberg rgoldberg added this to the 1.8.7 milestone Oct 30, 2024
rgoldberg added a commit to rgoldberg/mas that referenced this issue Oct 30, 2024
Update linting for access control on extensions.

Resolve mas-cli#307

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
rgoldberg added a commit to rgoldberg/mas that referenced this issue Oct 30, 2024
Update linting for access control on extensions.

Resolve mas-cli#307

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants