You can't save a password for later that way. sudo, as well as su, ssh, sftp, scp, and most other sane authentication systems, only accept passwords from a terminal, not from a script, as a security feature. There's other options, though.
You could run the entire script under a different user. Not as root -- that's almost never a good idea -- just a different user that sudo won't require a password to /sbin/poweroff with. So you type a password to get into the script and it can do what it needs to from there.
Or you could run a little loop in sudo that waits for /proc/<shell's pid> to stop existing before running a /sbin/poweroff or /sbin/reboot respectively.
Or you could run a little loop in sudo that waits for /proc/<shell's pid> to stop existing before running a /sbin/poweroff or /sbin/reboot respectively.
if i understand this correct , you mean let the sudo command check if the converting is done like every 5 minutes so it remembers the password when you entter it at the beginning of the script? or do i misunderstand you?
if i understand this correct , you mean let the sudo command check if the converting is done like every 5 minutes so it remembers the password when you entter it at the beginning of the script? or do i misunderstand you?
Yes, you understand me. Not that it runs sudo every 5 minutes -- you run sudo once, and the command it runs checks every few minutes...
Hi Team,
I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder.
Eg:
parent folder --> /Interface/data/test/IN
Sub folder -->/Interface/data/test/IN/Invoice20180607233338
Subfolder will be always with timestamp... (6 Replies)
Hi All,
I have to requirement to write a shell script to move file from one folder (A) to another five folder (B,C,D,E,F) and destination folder should be blank. In not blank just skip.
This script will run as a scheduler every 2 minutes. It will check number of files in folder A and move 1 to... (9 Replies)
hi,
i have a problem when i try to install Proliant support pack into a server with rhel 5.2
sv556:#/tmp/psp# ./hpsum -silent
./hpsum: error while loading shared libraries: libfreetype.so.6: cannot open shared object file: No such file or directory
i have already installed library... (3 Replies)
I need a bash script that will.
So here is what I made so far.
1. Convert video files to iPhone format
2. MV converted video to new directory (with domain.com attached to it)
4. Copy a NFO file (from another directory) and add some conversion information
5. Delete old directory
torrent... (6 Replies)
found a few ffmpeg posts and after a few unsuccessful attempts, I have found a solution :)
to encode an avi to to an nokia e71 recognized mp4 format:
ffmpeg -y -i inputFILE.avi -acodec aac -ab 72k -s 320x176 -aspect 16:9 -vcodec h264 -b 300k -qcomp 0.6 -qmin 16 -qmax 51 -qdiff 4 -flags +loop... (2 Replies)
Hi all,
I have a folder '/samplefolder' in which i have some files like data0.txt, data1.txt and data2.txt.
I have to search the folder for existence of the file data0.txt first and if found have to copy it to some other file; next i have to search the folder for existence of file... (5 Replies)
I have my main script calling another script to retrive a "ls -alt" of a directory that's located in a remote location I'm sftping into.
main.sh
#!/bin/ksh
getLS.sh > output.txt
getLS.sh
#!/bin/sh
/home<..>/sftp <host@ip> <<!
cd /some/dir/Log
ls -alt
quit
!
Basically I'd like to be... (2 Replies)