Operating System - HP-UX
1752565 Members
5621 Online
108788 Solutions
New Discussion юеВ

date command gives rubbish o/p

 
SOLVED
Go to solution
radi_1
Frequent Advisor

date command gives rubbish o/p

Hi,
crontab fails and gives the the following error;
-tty type could not open /dev/tty for reading
-stty not a typewriter.

The crontab excutes a tar opration on a dumb file to which date command o/p is added to its name (e.g dumb030408)for today dumb file.
I excuted the date command as root on a CDE session and it generated a rubbish o/p,
but when date is excuted as other user(oracle)it was o.k
I checked $TERM ,its vt100
I checked root's .profile,it looked ok ,anyway I do not expect anyone to have tampered with it.
Note;if root excutes date command on console it gives meaningfull o/p:
Thu Apr 3 10:32:00 WAT 2008
Please help
never take simple maters for granted
6 REPLIES 6
Dennis Handly
Acclaimed Contributor

Re: date command gives rubbish output

I don't see any date commands. I see an example of an illegal .profile, not set up to play in the majors.

You'll need to condition anything in your .profile to not execute tty type commands if you are not on a tty:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1198910
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1162063
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1155025
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1146959


Steven E. Protter
Exalted Contributor

Re: date command gives rubbish o/p

Shalom,

>>
I don't see any date commands. I see an example of an illegal .profile, not set up to play in the majors.
<<
I seriously doubt anyone outside the US would understand this terminology.

What it means is your profile or .profile environment is wrong.

Possible fixes:
Copy a .profile from a working machine.

env >machine1.txt
env >machine2.txt

put them on the same machine and then use diff to compare.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Kapil Jha
Honored Contributor

Re: date command gives rubbish o/p

You may as well try
>stty sane
command if ur .profile is not very bad ;)
BR,
Kapil
I am in this small bowl, I wane see the real world......
Kapil Jha
Honored Contributor

Re: date command gives rubbish o/p

From Melvyn
eval `ttytype -s`
tset
by
http://forums12.itrc.hp.com/service/forums/questionanswer.do?threadId=1218881

may help,
BR,
Kapil
I am in this small bowl, I wane see the real world......
Dennis Handly
Acclaimed Contributor

Re: date command gives rubbish output

>SEP: I seriously doubt anyone outside the US would understand this terminology.

(Not ready for prime time? :-)
Actually not usable in cron/at jobs.

>Copy a .profile from a working machine.

This is not likely to work since the HP supplied .profile is broken as Bill says in some of the provided links.

Bill Hassell
Honored Contributor
Solution

Re: date command gives rubbish o/p

> crontab fails and gives the the following error;
> -tty type could not open /dev/tty for reading
> -stty not a typewriter.

This is caused by the job running /etc/profile and .profile from an su command. The profiles must have all the terminal-specific commands like ttytype and tabs protected because there is no terminal in cron. But these errors should not have caused the script to stop, so you need to add: set -u at the start of the script and run it from cron. You'll now get a trace of the script. The errors will be more obvious.

> I executed the date command as root on a CDE session and it generated a rubbish o/p,

and the rubbish output is???

Be aware that running scripts from a login shell with a keyboard is very different from running as a cron job.

> I checked $TERM ,its vt100

Meaningless in cron which is why the profiles should be rewritten to protect the terminal-only commands.

You showed that the output from date was appended to the filename: dumb030408 but said the date command looks like this:

Thu Apr 3 10:32:00 WAT 2008

So the script to perform the tar command does not use a plain date command but one with a formatting string such as:

date "+%m%d%C"


Bill Hassell, sysadmin