If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > C-Programming under SCO-Development

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-28-04, 15:27
fla5do fla5do is offline
Registered User
 
Join Date: Oct 2003
Location: Germany
Posts: 138
Question C-Programming under SCO-Development

Is here anyone who can help me out in C-programming under
SCO-Unix Development

First, I need a funktion or command to read the systemdate and the systemuname.



Thanks
__________________
Greetings from germany
Peter F.
Reply With Quote
  #2 (permalink)  
Old 03-03-04, 08:57
skd skd is offline
Registered User
 
Join Date: Sep 2003
Posts: 71
something like this?

hp91>cat showdate.c
#include <stdio.h>
main()
{
char ucmd[100];
sprintf(ucmd,"echo system date is `date`");
system(ucmd);
sprintf(ucmd,"echo hostname is `hostname`");
system(ucmd);
}
================================
hp91>cc showdate.c
hp91>a.out
system date is Wed Mar 3 08:55:36 EST 2004
hostname is hp91
Reply With Quote
  #3 (permalink)  
Old 03-03-04, 14:19
fla5do fla5do is offline
Registered User
 
Join Date: Oct 2003
Location: Germany
Posts: 138
Hi skd,
thanx for your interest to my problem.

It is not the real way that I want to do. I need the result in a variable and not on screen.

I give you some more details.

I wrote a shell script witch bild a number for a second login passwort.
Now a want do do it by a C-programm because other users can not read the opperations in the binary executable file. To build this number I used
the last two digits from uname(allways 1-99 at the end), day, month, year and a fix digit in this vain.

FIX="1234"
UNAME=`uname -n | awk '{
len=length($1)
dummy=substr($1, len-1, 2)
print dummy
}'`
ALGO=$FIX
ALGO=`expr $ALGO * $UNAME `
ALGO=`expr $ALGO * $DAY `
ALGO=`expr $ALGO * $MONTH `
ALGO=`expr $ALGO * $YEAR `
# after this, I take the last digit from $ALGO and divide $ALGO for
# n times whith the value "3" as an integer without floating point
LAST=`echo $ALGO | awk '{
lang=length($1)
dummy=substr($1, lang, 1)
print dummy
}'`

while [ "$LAST" != "0" ]
do
LAST=`expr $LAST - 1 `
ALGO=`expr $ALGO \/ 3 `
done

echo $ALGO > myfile
__________________
Greetings from germany
Peter F.
Reply With Quote
  #4 (permalink)  
Old 03-10-04, 10:28
S_Scheible S_Scheible is offline
Registered User
 
Join Date: Feb 2004
Posts: 17
Why don't you just make the file unreadable for others?
# chmod go-r file
Writing a program in C because it is not immediately readable by humans is (imo, sorry) poor security. There are tools to reverese the compilation process after all.
Reply With Quote
  #5 (permalink)  
Old 03-10-04, 13:48
fla5do fla5do is offline
Registered User
 
Join Date: Oct 2003
Location: Germany
Posts: 138
Hi S_Scheible ,
thanx for answer. The problem is as followed.
If our support team have a shell on systemconsole they can change to root, because they do any administrative workings. The second login passwort only works by using the online shell over modem or ISDN.
__________________
Greetings from germany
Peter F.
Reply With Quote
  #6 (permalink)  
Old 03-10-04, 17:44
S_Scheible S_Scheible is offline
Registered User
 
Join Date: Feb 2004
Posts: 17
Quote:
Originally posted by fla5do
If our support team have a shell on systemconsole they can change to root, because they do any administrative workings. The second login passwort only works by using the online shell over modem or ISDN.
I see. Hmm I think you should read
# man 2 time
and the manpages it references. One of the later should be able to format the time as you see fit.

# man 2 uname
should solve the other, uname-related problem.

I was going to suppose sudo, but I guess your support team has to fulfill various administrative tasks, not just a few, so this is not an option.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On