Hi All,
I tried to get an answer for this one, but no go. So pls post your suggestions and help me.
On an AIX system, my requirement is to build and run a script as root. This script does multiple actions. One of the tasks is to append a job to a normal users' crontab.
My basic idea is like this:
cronentry="5 * * * * /tmp/dummyscript"
crontab -u myuser -l > /tmp/cronfile
print "$cronentry >> /tmp/cronfile"
Now /tmp/cronfile contains the updated cron file. My question is, how to put this content back into myuser's cron file?.
The constraints are:
1)Other portions of the script needs root privileges. So normal user cannot execute the script.
2)It is not possible to manually edit cronfile, because this and other steps should be part of a big script that would be executed on a number of systems.
3)Root cannot give the command
This would "create or replace your crontab file by copying the specified file, or standard input if file is omitted or - is specified as file , into the crontab directory, /var/spool/cron/crontabs. The name of your crontab file in the crontab directory is the same as your effective user name".
This command would modify the crontab of invoking user, which is root in my case. But I want to modify the crontab of 'myuser'.
How to modify the syntax to achieve this?.
As the remaining portions of the script are in ksh, I am not looking at the perl/expect solution.