I have written a shell script which in turn calls another script, but the second one prompts for password. I want to supply the password and pass the prompt without user begin notified.  Here is my script:  su - s3 -c "su.sh"   I trided :  su - s3 -c "echo pass | su.sh"   But I got an error:  standard in must be a tty   Updated:  The screenshot of commands.    I also tired :   su - s3 -c "echo mypass|sudo -S su.sh"   but another error comes up:   sudo: sorry, you must have a tty to run sudo   su.sh commands:  if [ ! -n "$IS_WINDOWS" ] then    /bin/su root -c "...." fi
123757
I have a script run from a non-privileged users' crontab that invokes some commands using sudo. Except it doesn't. The script runs fine but the sudo'ed commands silently fail.   The script runs perfectly from a shell as the user in question. Sudo does not require a password. The user in question has (root) NOPASSWD: ALL access granted in /etc/sudoers. Cron is running and executing the script. Adding a simple date &gt; /tmp/log produces output at the right time. It's not a permissions problem. Again the script does get executed, just not the sudo'ed commands. It's not a path problem. Running env from inside the script being run shows the correct $PATH variable that includes the path to sudo. Running it using a full path doesn't help. The command being executed is being given the full path name. Trying to capture the output of the sudo command including STDERR doesn't show anything useful. Adding sudo echo test 2&gt;&amp;1 &gt; /tmp/log to the script produces a blank log. The sudo binary itself executes fine and recognizes that it has permissions even when run from cron inside the script. Adding sudo -l &gt; /tmp/log to the script produces the output:       User ec2-user may run the following commands on this host:   (root) NOPASSWD: ALL    Examining the exit code of the command using $? shows it is returning an error (exit code: 1), but no error seems to be produced. A command as simple as /usr/bin/sudo /bin/echo test returns the same error code.  What else could be going on?  This is a recently created virtual machine running the latest Amazon Linux AMI. The crontab belongs to the user ec2-user and the sudoers file is the distribution default.
70572
I have created a .bat file which automatically takes the SSH server (Jump Server) access. Now, I have couple of commands which I would like to hit in that window.  For an ex. (To take root access)  usrun -u root rush   With this command, it'll ask me to enter the password.  So, how can I achieve this entirely through .bat file?
5539
I used the following bash to shutdown remote computers,but for each computer,I must input the password for it.Is it possible to input the password Automatically?   #!/bin/bash  ssh -t root@192.168.1.11 "sudo poweroff" ssh -t root@192.168.1.12 "sudo poweroff" ssh -t root@192.168.1.13 "sudo poweroff" ssh -t root@192.168.1.14 "sudo poweroff" ssh -t root@192.168.1.15 "sudo poweroff" ssh -t root@192.168.1.16 "sudo poweroff" ssh -t root@192.168.1.17 "sudo poweroff" ssh -t root@192.168.1.18 "sudo poweroff" ssh -t root@192.168.1.19 "sudo poweroff" ssh -t root@192.168.1.20 "sudo poweroff" ssh -t root@192.168.1.21 "sudo poweroff" ssh -t root@192.168.1.22 "sudo poweroff" ssh -t root@192.168.1.23 "sudo poweroff" ssh -t root@192.168.1.24 "sudo poweroff" ssh -t root@192.168.1.25 "sudo poweroff" ssh -t root@192.168.1.26 "sudo poweroff"
18955
I want to be able to 'su' to a specific user, allowing me to run any command without a password being entered.  For example:  If my login were user1 and the user I want to 'su' to is user2:  I would use the command:  su - user2  but then it prompts me with   Password:
77998
This is the first time it has happened to me where I am using the su command and it actually displays the password on the terminal and doesn't stay hidden. Here is my code snippet:   sshpass -p "password" ssh -q username@74.11.11.11 "su -lc 'mkdir temp/'"   Code explanation:  I am accessing a remote server and trying be root on that server to create a folder. In doing so I have to use the su command and it prompts me for the password. When I enter the password, it gets displayed and doesn't stay hidden. How do I fix that?
36380
On busy days, I'd like to run   $ ./configure &amp;&amp; make &amp;&amp; sudo make install &amp;&amp; halt   on the night and go to bed, hoping the application would automatically be installed. But what I see the next day is the screen where sudo asks me for the password. So how could I run sudo with password in one command line, or is there any other method to do this?
44440
I have a local script that I want to run on several remote servers. The command syntax I'm using is:  ssh &lt;remote_server&gt; "bash -s" &lt; ./local_script.sh   This works fine, and even lets me pass parameters to local_script.sh. However, I'd really like to pass an input file to it, as in:  local_script.sh &lt; local_file.txt   Combining these two statements gives:  ssh &lt;remote_server&gt; "bash -s" &lt; ./local_script.sh &lt; local_file.txt   When I run this, I get  bash: line 1: FOO: command not found bash: line 2: BAR: command not found bash: line 3: BAZ: command not found ...   where FOO, BAR, BAZ, etc. are the first word on each line of local_file.txt:  FOO     FOO_PARAM1 BAR     BAR_PARAM1 BAZ     BAZ_PARAM2 ...   So, it looks like "bash -s" on the remote server is interpreting local_file.txt as a script file, instead of an input file to local_script.sh. Is there any way to fix this (other than creating a wrapper script)?
37024
I need to run a (Tcl, or whatever) script on a remote Unix machine, from a (local) Windows command shell, and I want the stdout/stderr of the script to show up in the Windows CLI. The exit code would also be useful.  Is this possible using ssh (putty)? Or by any other means?  Thanks!
95791
Is there some way I can run a Bash script as root without being prompted for a password every time? I'm attempting to automate the process of starting my LAMPP install, which requires me running a couple of sudo commands to start and stop services. Optimally, I'd like to build this into an executable file, so all I'd have to do is click an icon. ;)  Obviously, I have the password, so that's not an issue. I just want to take my laziness one step farther and not have to enter it every time I start my localhost. After all, that's what programming is all about, right?
34801
I want to turn my system on automatically every day. So I use the below code in my Python script, but sudo asks me for a password every time:  os.system('sudo sh -c "echo date \'+%s\' -d \'+ \        24 hours\' &gt; /sys/class/rtc/rtc0/wakealarm"')   How can I run this script without sudo asking for the password every time?
60831
Suppose I run a command like this in the terminal:  ~$ echo 'sleep 2; echo "hello!"' | sh   then start typing the next line. After two seconds the words "hello!\n" will be inserted into whatever I'm writing. I know there is a workaround to this (pressing up then down which refreshes the prompt), however on other systems that don't have history---eg, using a MUD through telnet---this is not possible.  Does anybody know of an ncurses app or terminal emulator that separates stdin from stdout? This seems pretty easy to make in ncurses, you just have to use some clever dup2s, but before I make it I want to know if someone has done it before.  Any other solutions to the main problem are welcome, as well.
74846
I want to scp a file to a remote host, and from there, run a command on the file, and exit the remote session. If I write a usual script, call scp and then ssh, I am prompted to enter two passwords. Is there a way to copy, ssh, and run a command on a remote machine with one password?   Also how to write scripts which need to interact with user to enter passwords?  I do not want to use "read" as it's not safe. I do not want to use passwordless ssh, since my private key file may be compromised, which is even worse. I read something about "expect" but not sure if it's the right tool.
62110
I want to write the output of only sudo command to some file i.e. the line which I get on terminal after writing sudo i.e.   [sudo] password for user:   If I use sudo ls &gt; file or sudo ls 2&gt; file then I get the stdout and stderr respectively of the whole command. Also I can't use sudo &gt; file or sudo 2&gt; file, then I will get error that I should use some options or command after sudo. So, is it possible to achieve?
30876
I was wondering how to run a command as another user from a script.  I have the script's owner set as root. I also have the following command being run within the script to run the command as the hudson user:  su -c command hudson   Is this the correct syntax?
18464
I have one script to allow for one user to run. The string calling it from the command line looks like  ./script path/to/folder -a option='value'   When I try to add it to the other commands in Cmnd_Alias line, sudo blames sudoers file for incorrect syntax. How can I set such commands properly?
651
I have a complex command that I'd like to make a shell/bash script of.  I can write it in terms of $1 easily:  foo $1 args -o $1.ext   I want to be able to pass multiple input names to the script. What's the right way to do it?    And, of course, I want to handle filenames with spaces in them.
27279
I used to have a password prompt but then I, from somewhere in User Accounts, unchecked "Require a password for login." Now, I want Ubuntu to prompt for a password again at login screen, mainly because I have to manually unlock the login keyring whenever I access Dash or other services, which is a pain at best.  I also searched another question, namely . It was of no help because the OP's question is "I have a password but Ubuntu doesn't ask for it."  Also, the two answers provided there don't solve my problem at all. They discuss completely other things.  Is there no simple mechanism? Because intuitively, if there's a checkbox option to bypass password requirement, there should be an equally hassle-free facility to again require the password.