tried Shell-Script wait here document
95.627
solution 1
x11vnc
expects your standard input to be a terminal, and changes the terminal mode to avoid repeating the password as you type it. If standard input is not a terminal, thepigsty
Calls to turn echo off and back on fail, hence the warning you see.
In fact, wait for a solution. Try this script (not tested):
#!/usr/bin/expect -fspawn x11vnc -storepasswd ~/.vnc/passwdexpect "password:" {send "swordfish" "\r"}expect "password:" {send "swordfish" "\r "} wait " Schreiben*\?" {send "y\r"}
Alternatively, if possible, use a non-RFB authentication method (-password
or an SSL client certificate).
solution 2
Another way to avoid these warning messages is to runx11vnc
in a pseudo-terminal created by a UNIX command (seeUsing pseudo terminals (pty) to control interactive programs). that goes with meroad map
command or tools likepdip
("Dialogue programmed with interactive programs").
Mac OS X 10.6.8 warning messages for the lack of a pseudo terminal forx11vnc
:
# x11vnc 0.9.14sudo x11vnc -storepasswd ~/.vnc/passwd << ENDDOCpasswordpasswordyENDDOC# Enter the VNC password: stty: stdin is not a terminal## Confirm the password: # stty: stdin is not a terminal# Type the password to ~/ .vnc/senha? [y]/n Senha recorded in: ~/.vnc/passwd
solutions with theroad map
Domain:
# GNU-Skriptbefehleudo script -q -c 'x11vnc -storepasswd ~/.vnc/passwd' <<ENDDOC /dev/nullpasswordpasswordyENDDOC# ... oder ...printf '%s\n' 'contraseña' 'contraseña' 'y ' | sudo script -q -c 'x11vnc -storepasswd ~/.vnc/passwd' /dev/null# FreeBSD-Skriptbefehleudo script -q /dev/null x11vnc -storepasswd ~/.vnc/passwd <<ENDDOCcontraseñacontraseñayENDDOC
solution 3
sudo has an option-S
this allows you to read the password from STDIN.
[[Email protected]~]$ tail -1 /etc/shadowtail: Cannot open `/etc/shadow' for reading: Access denied[[Email protected]~]$eco'[Email protected]!' | sudo -S cola -1 /etc/shadownfsnobody:!!:15891::::::
Here is an example script to demonstrate the process:
#!/bin/bashfunction hr { perl -e 'print "-" x 80, "\n";'} hrread -p "Bitte geben Sie Ihr sudo-Passwort ein: " -s sudopasswdechohrecho "-sudo run: tail - 1 /etc /shadow"tail -1 /etc/shadowhrecho "+sudo run: tail -1 /etc/shadow"echo "$sudopasswd" | sudo -S tail -1 /etc/shadowhrecho "-sudo execute: ls -la /root/"ls -la /root/hrecho "+sudo execute: ls -la /root/"echo "$sudopasswd" | sudo -S ls -la /root/hr
Your script would simply need to do something like this:
read -p "Please enter your password sudo: " -s sudopasswdecho "$sudopasswd" | sudo -S x11vnc -storepasswd ~/.vnc/passwd
This allows you to use sudo commands in your script without having to hardcode a password.
Alternatively, you could give your user or a subset of users the ability to run x11vnc with sudo without a password, but add a line like this/etc/sudoers
:
Benutzer ALL= ( root ) NOPASSWD : /route / a / x11vnc
or create onevncusers
Group, add users to this group and add the following/etc/sudoers
:
%vncusers ALL=(root) NOPASSWD: /ruta/a/x11vnc
To share:
95.627
Similar videos on Youtube
04:20
Unix and Linux: stty bash script error: stdin: bad ioctl for device
Roel van de Paar
696
01:17
How to avoid error stty: 'std input': ioctl incompatible with device?
Roel van de Paar
72
04:13
Arduino: ioctl inappropriate for the device (4 solutions!)
Roel van de Paar
27
01:40
Unix and Linux: channel to adopt: stty: stdin: inappropriate ioctl for the device (2 solutions!)
Roel van de Paar
21
01:53
Should I try removing "inappropriate device ioctl" in the strace output to a bash script?
Roel van de Paar
18
author of
Jarek
You may be interested in the story of SE presenter Monica Cellio and how she was treated unfairly by the administration of this site. More information here. An update is available. Hopefully, we can create a fairer environment for content creators and moderators in the future.
Updated September 18, 2022
Comments
-
Jarek 4 fun
I'm using here-documents in a bash script to automate installation and configuration, which often require a password. I type the password once and the script passes it to various commands. In most cases this is easily handled with the document approach here. However, in one case I get this error:
Enter VNC password: stty: stdin: ioctl not supported by device Verify password: stty: stdin: ioctl not supported by device
Please note that this error message comes from
x11vnc save password
(Do not givesudo
.)my problem is related to
x11vnc -storepasswd
and here is my code:sudo x11vnc -storepasswd ~/.vnc/passwd << ENDDOCsenhasenhasENDDOC
This obviously doesn't work (because of the bug). I would appreciate a working example of the implementation.
sudo x11vnc -storepasswd ~/.vnc/passwd
in a script.If it helps, the prompts look like this:
Enter the VNC password:
Confirm password:
Write the password to /home/user/.vnc/passwd? [yes]/nIt is used
wait
be a better solution? If so, how would I use it in this case? (never usedwait
before, but I've seen a lot of examples since I asked this question and I can't seem to figure them outwait
working alone.)(Video) Unix & Linux: bash: cannot set terminal process group (-1): Inappropriate ioctl for device -
Jarek more than 9 years
Thank you. However, the error does not come from
sudo
comes fromx11vnc save password
. -
Jarek more than 9 years
Thank you. However, the error does not come from
sudo
comes fromx11vnc save password
. I have tried differentwait
It's getting closer and I can't hit it. an example withwait
to enter a passwordx11vnc save password
It would be greatly appreciated. I'll update my question to avoid further confusion. -
Gilles 'So stop being mean' more than 9 years
@MountainX Correct, sorry I misunderstood the question. Here's an expectation script (totally untested).
-
Jarek more than 9 years
Thank you so much. Your untested script gave me some additional clues, but ultimately it doesn't work perfectly either. the mistake is simple
Enter the VNC password: Usage: Send the string [args].
On the lineExpecting "Password:" {send "Swordfish" "\r"}
. I'm not sure how to fix this. Expect seems to be a very demanding tool because I've been struggling with this particular problem for hours with no results so far. -
Jarek more than 9 years
The error (previous comment) came from
send "fish-sword" "\r"
and it was solved bysend "fish-sword\r"
. However, the solution still doesn't work. No passwords are written to ~/.vnc/passwd. I still don't know why. Like I said, I've seen this result despite trying everything I can think of so far. -
Jarek more than 9 years
By the way, the same commands used in your
wait
Work solution with manual input. they don't work on itwait
script or any variation of it that you have tried so far. - (Video) Shell Scripting for DevOps | Zero 2 Hero Part-2 | Shell Scripting Interview Q&A | #devops
alper more than 2 years
I have the following error:
spawn: command not found, line 3: expected: command not found
should i insert?.zshrc
Archive? -
Gilles 'So stop being mean' more than 2 years
@alper This is a wait script, not a shell script. You have to put the code in a file, make it executable and run it. And you need to install
wait
.
newer
Why is a PNG drop shadow grainy in Flutter web app?
How to fix crashes detected by Google Play Store for Flutter app
Cupertino DateTime Picker stops scrolling behavior
Why does awk -F work for most letters but not the letter "t"?
Flutter change hover color and icon color but not working
How do I print to USB using Flutter Desktop and connect to the printer?
Critical issues have been reported with the following SDK versions: com.google.android.gms:play-services-safetynet:17.0.0
Flutter Dart: get localized country name from country code
navigatorState é nulo ao usar pushNamed Navigation onGenerateRoutes de GetMaterialPage
Android SDK Manager Not Found - Flutter Doctor Error
Flutter Laravel push notification without using third parties like (Firebase, Onesignal, etc.)
How to change color of ElevatedButton when entering text in TextField