Hi all,
I have a script where every line needs to be prefixed with sudo.
I was advised to run it as $ sudo /path/to/file.sh
This script needs to be scheduled in crontab to run. If I run it as above, will I be prompted for a password?
Also, one of the lines in the script is;
scp -r root@rem_server:/source/dir /local/dir
Does that mean I will have to provide two passwords: one for sudo and one for root?
Thanks,
Hello.
How can I write an Script that enter my password for "sudo" command automatically?
for example, I want to run a command that need root permission and when I write it in a bash script, it ask me "sudo" password for user but how can I automate it?
Can it possible for other program like logging via SSH too?
Thank you.
I would like to tar up some system logs with core files as a normal user through a script. However these core files are owned by root.
Of course I get "cannot read directory ...: Permission denied"
Is there a good way to grab these core files through a script? From searching around, I get that the best way is to modify the sudoers file, then run the script with sudo. Is this considered the safest and best way?
Thanks!
hi guys,
sick of typing sudo yum install package
so i wrote...or rather am trying to right a simple script to do this
with a simple command:
heres what i have:
#!/bin/bash
echo "Enter package name to install..."
read $P
sudo yum install $P
it doesnt seem to want to take the variable...it just runs
sudo yum install ...$p is ignored...i also tried "$p" but this
doesnt work either...what is the correct syntax to get a command to read a variable...is this possible...aaaaaaah it must be.
This is my script and the syntax to run this script is give ip and next will be the file or script you want to perform on remote server
#!/bin/bash
# The private key used to identify this machine
IDENTITY_KEY=/home/adnew.pem
syntax()
{
echo "Syntax: Ec2.sh server_ip scriptFile]"
echo "For example: ./Ec2.sh server_ip scriptFile"
exit 1
}
if [ $# -ne 2 ]
then
echo not enough arguments
syntax
fi
echo "Running script $2 on $1"
ssh -ttq -i $IDENTITY_KEY ec2-user@$1 sudo -i 'bash -s' < $2
exit
exit
echo "Done"
on script file i have give for testing
touch /root/test
ls /root/test
exit
exit
it makes the file but do not show the ls output by giving error
tcgetattr: Inappropriate ioctl for device
exit
what I have to do ??
Hi All,
I have perl script which I am trying to run on 1st Monday via cron job.
So I scheduled it as follows:
0 0 1-7 * * root ["$(date '+%a')" = "Mon"] && /usr/bin/perl script.pl
But then it didn't run so checked cron log and it seemed like its missing the command. so added a \ in front of %a and then it picked up the whole command as per cron log.
But still it didnt ran the script. I then change the script to just && echo "test">/tmp/test
Still nothing. if I run it as /usr/bin/perl script.pl it runs though
Thanks in advance.
guys help me plz............
i have install conky in my kali linux by using this command.
sudo apt-get install conky
sudo apt-get install conky-all
every thing is working fine but i wanted to change my default conky script so i used these command ..
leafpad ~/.conkyrc
to open my default conky script page but it open only blank page ...where is my default conky script page i can not find it?????
how can i find my deafult conky script page........... thanks
Hi all,
I am trying to write a script that syncs files from source to destination. I have one centralized server that can ssh to any servers without pw. Now when I run the script, it can ssh to source server perfectly fine, but you need to enter password for destination server. Was wondering how I can clean this up before I start using case statements
Below is a sample I wrote
#!/bin/bash
#This scripts syncs shit
echo "Type in ID: "
read ID
echo "Type in Server : " #source server
read S
echo "Type in Destination Server: "
read DS
if [ $S == 9 ]; then
ssh -t "root@"$S"webserver1" "rsync -av /home/rlui/"$ID "root@"$DS"webserver2:/home/rlui/";
ssh -t "root@"$S"webserver1" "rsync -av /home/rlui/tmp/"$ID "root@sl"$DS"webserver2:/home/rlui/tmp/"
exit 1
where S and DS are cluster numbers
I apologize in advance if I am not clear on anything
Hello,
I am getting the follwoing error for Red Hat Enterprise Linux Server release 6.6
sudo su -
sudo: >>> /etc/sudoers: syntax error near line 118 <<<
sudo: parse error in /etc/sudoers near line 118
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
cd /etc/sudoers.d/
-bash: cd: /etc/sudoers.d/: Permission denied
Could you help me to figure it out. As a root user am able to access but as normal user it is not allowing to sudo su - command.
vi /etc/sudoers.d/access
username ALL=(ALL) NOPASSWD: ALL
Please let me know if any additional formation required.
Hi,
I have written one script which is connecting to the the daabase and generating one CSV, it is running fine when i ran it manually though it is throwing any warning but CSV is genearting and working fine but same script when i have configured in crontab not working and giving error, kindly help.
script contents:
#!/bin/bash
sqlplus -s /nolog << EOF
CONNECT plmc/plmb@whb
@csvgenerator.sql
end;
/
EOF
-----------------------------------
Script running successfully as below, though it is giving below message but running fine
$ sh test.sh
SP2-0734: unknown command beginning "sqlplus ct..." - rest of line ignored.
Session altered.
CSV geneartaed
Same Script giving error while triggering by crontab as below
$ sqlplus: not found
I am toying around with a LFS system and I am suddenly having trouble with sudo not finding binaries in the standard superuser only binary dirs (/sbin /usr/sbin). I am using sudo version 1.8.10p3. The sudoers file parses correctly and I did not modify except to allow users in the wheel group to be able use sudo to call any command. So I imaging something is wrong with the $PATH variable but I am not sure on what it is.