How to send a print job to all cloudprint printers

445 views
Skip to first unread message

Jay Lee

unread,
Jan 9, 2018, 7:42:46 AM1/9/18
to google-ap...@googlegroups.com
Context: Due to crbug.com/798706 your cloudprint printers may be showing as offline. The bug is fixed but in order to resolve the issue for each printer the printer needs to successfully print a document. This can be automated for many printers with GAM.

# Create a file with one space (no need to waste toner)
echo " " > blank.txt

# Get a list of all printers and submit the blank file
gam print printers | gam csv - gam printjob ~id submit blank.txt

Please do keep GAM related questions here to keep traffic off the (already very busy) bug.

Jay

+KimNilsson

unread,
Jan 9, 2018, 10:24:06 AM1/9/18
to GAM for G Suite
Thanks, Jay.

But, how do you do this when your admin isn't the GCP admin?
Is it possible to insert a reference to the gcp admin user somehow?

Jay Lee

unread,
Jan 9, 2018, 10:40:41 AM1/9/18
to google-ap...@googlegroups.com
If the user who owns / has rights to print to all your GCP printers isn't the super admin you usually use with GAM you can just create a new auth file for the GCP admin:

#Windows DOS Shell:
set OAUTHFILE=oauth.txt-gcp

#Windows PowerShell:
$env:OAUTHFILE="oauth.txt-gcp"

#Linux / OSX:
export OAUTHFILE=oauth.txt-gcp

gam print printers        # you'll go through authentication again here, this time auth as your GCP admin

now you should be good to run the CSV command to send a print job to every printer.

Jay

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.
To post to this group, send email to google-apps-manager@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/ffb2acda-88e1-4f50-adae-235b9069a785%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Damion Williams

unread,
Jan 9, 2018, 10:54:50 AM1/9/18
to GAM for G Suite
Thank you for this Jay!

I'm seeing an issue where gam print printers does not report the offline printers on a specific domain. Only the online printers are appearing, as more come on line more are appearing. Was using 4.01 but updated to 4.40 and same issue. GAM's authenticated against the cloudprint owner account.

They still appear at https://www.google.com/cloudprint/#printers so doing it manually. 

Thank you,
Damion
 

Jay Lee

unread,
Jan 9, 2018, 10:59:50 AM1/9/18
to google-ap...@googlegroups.com
Damion,

Try using:

gam print printers status DORMANT,OFFLINE,UNKNOWN

to get the dormant devices also while also excluding printers already ONLINE.

My bad for not catching that.

Jay

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.

Jay Lee

unread,
Jan 9, 2018, 11:01:14 AM1/9/18
to google-ap...@googlegroups.com
Also, case is important. The statuses should be upper cased.

Jay

Damion Williams

unread,
Jan 9, 2018, 11:06:33 AM1/9/18
to GAM for G Suite
Fantastic thank you Jay, you saved me 30 minutes of really monotonous task. I owe you a beer! :o)

Many thanks
Damion

Paul D.

unread,
Jan 10, 2018, 6:44:31 AM1/10/18
to GAM for G Suite
First thank you so much, i just found you on github and GAM already saved me a lot of time!

I am trying to do the exact same thing and it's almost working with the following command :

gam print printers status DORMANT,OFFLINE,UNKNOWN | gam csv - gam printjob ~id submit blank.txt

But there is almost 20000 printers in our cloud so i end up getting the following error :

ERROR: unexpected response: <HTML>
<HEAD>
<TITLE>Too many requests.</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Too many requests.</H1>
<H2>Error 503</H2>
</BODY>
</HTML>

Is there a way to make GAM sleep between requests ? 

Paul

Kim Nilsson

unread,
Jan 10, 2018, 10:20:42 AM1/10/18
to Google Apps Manager
OMG, Paul!
That's the punishment for having so many printers. You are singlehandedly responsible for the deforestation of 2% of the woods of Amazonas. 😂

Jay Lee

unread,
Jan 10, 2018, 10:35:25 AM1/10/18
to google-ap...@googlegroups.com
Paul,

  Yes, CloudPrint quota seems to get upset if a single user sends many print jobs that fast. Try lowering GAM's threads:


You may even need to split pipe the printer list into a CSV file, split it into a few different pieces and send the jobs to each piece from different users.

A pain I know but easier than CTRL+P to each printer :-/

Jay

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.
To post to this group, send email to google-apps-manager@googlegroups.com.

Paul D.

unread,
Jan 17, 2018, 4:32:20 AM1/17/18
to GAM for G Suite
Thank you Jay,

I am close to a decent solution, but i still have one problem, after a while GAM ask me for credentials again and i have to authenticate on all account then relaunch my script.

Here is the relevant part of my script:
while [ blablab]; do ..
   echo "changing account to ${accounts[$currentAccount]}"
   export OAUTHFILE=${accounts[$currentAccount]}

   if [ $currentAccount -eq 2 ]; then
       let "currentAccount=0"
   else
       let "currentAccount+=1"
   fi

   if [[ $currentAccount -eq 2 && $err -ne 0 ]]; then
       rm error.log
       echo "over quota on all account, sleeping for 30 minutes"
       sleep 1800
   else
       rm part${n}
       let "n++"
   fi

 i don't get why i lost the credential :-/

Ryan Decker

unread,
Oct 18, 2019, 11:06:13 AM10/18/19
to GAM for G Suite
You mentioned this was resolved with a bug fix. I installed version 16 in August '19 and all my inactive printers are showing offline. I tried two printers and your fix worked. Will the two printers I tested go inactive? We have 500+ printers and sending print jobs regularly is not feasible and wasteful. Is there a newer version or another way to get printers all online. Also the printer connector service keeps stopping and I have to create a task schedule to restart every hour...
Reply all
Reply to author
Forward
0 new messages