sudo: sorry, you must have a tty to run sudo

Hi All,

I running a unix command using sudo option inside shell script. Its working well. But in crontab the same command is not working and its throwing
"sudo: sorry, you must have a tty to run sudo". I do not have root permission to add or change settings for my userid. I can not even ask sysadmin to do something for my userid. Is there work around or alternative to run the command sucessfully in crontab.

Is this Fedora? Anyway, the ONLY fix is:

visudo /etc/sudoers
comment out: #Default requiretty

And you have to have privilege. Can we know why no sysadmin is available?
If this is a production job, surely SOMEBODY will want to get it running.

i tried commenting out requiretty in sudoers but after that i am getting this error

sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: 3 incorrect password attempts

It means what it says. It wants to ask for a password and can't, because it has no terminal.

i know that ssh -t is a work around. just wanted to know some other way and tried bit of googling and got an update that commenting out requiretty from sudoers file will also fix the issue but it aint work.

any suggestions please

Show your code, please. We've reached the limit of what we can do for you without seeing what you're actually trying to do.

Sorry for the late reply,

Atcually, I have an user account in unix(RHEL) and from where I connect to other unix servers using ssh to do my work in that server. I have a script which connect to other servers and get the file from the server. example: kscp <server_name > <file location>. It connects to the respective server and get the file to the location destination of calling server. This script is provided by some other team, long ago. I do not have access to change the script. I am using that script(kcp) in my shell and fectching the file.(Its working good). Now if schedule my script in cron. Its not working.

Thanks.

Well, this is a problem. It's asking for a tty because it wants to ask for a password. Even if you defeat the tty problem, it's going to be asking for a password over that tty...

Any more ideas, please welcome.

Thanks

Did you try input redirection to a file or a here document? I know password requesting programs can be quite delicate on redirection, but ...