Skip to main content
Solved

Give specific string to script


mkolb
Forum|alt.badge.img+8
  • Contributor
  • 33 replies

Hello,

At the moment I'm facing some troubles with a script. I want to uninstall the EndPointProtector from CoSoSys.

They provide a remove script, which I want to start from a JSS script. The problem: you have to enter a pre-defined uninstall password. How could I pass this from my script to the other script?

I already tried something like this:

#The uninstall password
unpw="xxxxxx"

#This calls the EPP uninstaller script
cd /Library/CoSoSys/EndpointProtector/
echo "$unpw
" | ./remove-epp

But it didn't worked. I guess the problem is "remove-epp" is no command but an other script, so basically my script hands over the string to the launch command of the other script but not to the input method inside this remove-eps script...

Any ideas how I could solve this? It causes a lot of troubles right now for us....

Best answer by Nix4Life

@mkolb you might want to look at expect or passing the info via EOF.
Below is an example of how I used it in a self-destructing script to enroll via command line a few years ago:

#!/bin/sh
sudo jamf enroll -prompt << EOF
jssacountuser
jssacountuserpassword
localsshaccount
localsshaccountpassword
sleep 5
rm "$0"
View original
Did this topic help you find an answer to your question?

5 replies

Forum|alt.badge.img+13
  • Honored Contributor
  • 550 replies
  • Answer
  • January 19, 2018

@mkolb you might want to look at expect or passing the info via EOF.
Below is an example of how I used it in a self-destructing script to enroll via command line a few years ago:

#!/bin/sh
sudo jamf enroll -prompt << EOF
jssacountuser
jssacountuserpassword
localsshaccount
localsshaccountpassword
sleep 5
rm "$0"

mkolb
Forum|alt.badge.img+8
  • Author
  • Contributor
  • 33 replies
  • January 19, 2018

hi,

Thank you @Nix4Life ! I was able to solve this with expect. Thank you for the hint!


Forum|alt.badge.img+4
  • New Contributor
  • 4 replies
  • November 2, 2020

@mkolb Do you mind sharing what you did here using expect?


markopolo
Forum|alt.badge.img+8
  • Contributor
  • 57 replies
  • October 14, 2021
rob_c28 wrote:

@mkolb Do you mind sharing what you did here using expect?


@mkolb I would love to know the answer to this as well.


mkolb
Forum|alt.badge.img+8
  • Author
  • Contributor
  • 33 replies
  • October 15, 2021

@markopolo / @rob_c28 
Sure! This is how it worked in the end:

expect <(cat <<'EOD' spawn "./remove-epp" expect "Please enter your password for uninstall protection:" {send "####\\r"} EOD )

 

The spawn command starts the actual remove-script. At some point this remove-script will present the string "Please enter your password for uninstall protection:" in the terminal. The expect command is looking for exactly this string (you have to make sure, what ever dialog is showing up, you copy it 1:1 and case sensitive). With the send command you then can define which string should be "typed". The # represents the actual password, the \\r represents pressing enter after "typing" the string.

Hope this helps!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings