C SCRIPT

C SCRIPT

Post by Derek Smit » Tue, 05 Jan 1999 04:00:00



Hello there.

My company has recently installed a new UNIX based system and it has fallen
to me to manage the system.
However the company will not send me on any courses which may help in the
management of the system (I have no formal UNIX training. All I know I
picked up by stumbling about on the new system).

Anyway. To my problem.
I want to write a c script (using the vi editor) to enter a number and then
produce a list of numbers by adding and subtracting from the original
number.
The Basic program for this is something like:-

input "Enter the number", x
num = x
echo "The new list for number"; x "is:-"
echo " 1) " x + 2
echo " 2) " x - 3
etc.....

I hope this makes sense to someone. If not please excuse my ignorance.

I look forward to hearing from you.

Best wishes and happy new year to all.

Derek.

 
 
 

C SCRIPT

Post by Derek Smit » Tue, 05 Jan 1999 04:00:00


Hello there.

My company has recently installed a new UNIX based system and it has fallen
to me to manage the system.
However the company will not send me on any courses which may help in the
management of the system (I have no formal UNIX training. All I know I
picked up by stumbling about on the new system).

Anyway. To my problem.
I want to write a c script (using the vi editor) to enter a number and then
produce a list of numbers by adding and subtracting from the original
number.
The Basic program for this is something like:-

input "Enter the number", x
num = x
echo "The new list for number"; x "is:-"
echo " 1) " x + 2
echo " 2) " x - 3
etc.....

I hope this makes sense to someone. If not please excuse my ignorance.

I look forward to hearing from you.

Best wishes and happy new year to all.

Derek.



 
 
 

C SCRIPT

Post by Barry Margoli » Tue, 05 Jan 1999 04:00:00




>My company has recently installed a new UNIX based system and it has fallen
>to me to manage the system.
>However the company will not send me on any courses which may help in the
>management of the system (I have no formal UNIX training. All I know I
>picked up by stumbling about on the new system).

Sounds like a good time to start looking for a new job.  Any company that
won't hire trained personnel or provide training for the existing personnel
has enormous management problems.

Can they at least buy you some books?  I don't think you can learn what you
need simply by posting questions to the net every day.

Quote:>Anyway. To my problem.
>I want to write a c script (using the vi editor) to enter a number and then

Do you mean a C-shell script or a C program?  Do you have any programming
experience?

Quote:>produce a list of numbers by adding and subtracting from the original
>number.
>The Basic program for this is something like:-

>input "Enter the number", x
>num = x
>echo "The new list for number"; x "is:-"
>echo " 1) " x + 2
>echo " 2) " x - 3
>etc.....

It's been a long time since I programmed in BASIC, but I used to be pretty
proficient at it, and that doesn't look like it.  Doesn't BASIC use PRINT
rather than ECHO?

The Bourne shell script would be:

#!/bin/sh
echo "Enter the number"
read x
echo "The new list for number $x is:-"
echo " 1)" `expr $x + 2`
echo " 2)" `expr $x - 3`

--

GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Don't bother cc'ing followups to me.

 
 
 

C SCRIPT

Post by J. S. Jense » Tue, 05 Jan 1999 04:00:00



> Anyway. To my problem. I want to write a c script (using the vi editor) to
> enter a number and then produce a list of numbers by adding and subtracting
> from the original number.
> The Basic program for this is something like:-
> input "Enter the number", x
> num = x
> echo "The new list for number"; x "is:-"
> echo " 1) " x + 2
> echo " 2) " x - 3
> etc.....

Many, many ways of doing this.  You could do it shell, in C, or I suggest in
bc.  Your system probably has bc.

#!/usr/bin/bc -q
print "Enter the number:  " ; x = read()
num=x
print "The new list for number ",x" is:-\n"
print " 1) ",x+2
print " 2) ",x-3
...

chmod +x the above file, and run it.

man bc
man chmod

for more info.

bc is a wonderful program for doing quick maths.

--
J. S. Jensen

http://www.paramin.com

 
 
 

C SCRIPT

Post by brian hile » Thu, 14 Jan 1999 04:00:00



> My company has recently installed a new UNIX based system and it has fallen
> to me to manage the system.

Your situation is alas a complex one; surely any company is never
small enough to find no financial incentive to providing adequate
materials, documentation, and training. Why, people in your situation
have been actually known to grow to despise Unix! Which is a shame
becuase once the intimidation factor is over, Unix really is a workable,
elegant, and (yes!) simple OS.

May I suggest that:

1) You don't script in csh. Every other week there is a thread that
inevitably ends with this warning against using csh for non-interactive tasks.

2) I am nothing if not flexible. Perhaps under the circumstances
the best solution is to make use of the considerable amount of
quality source code available to Unix. Since you already know BASIC,
then why don't you download it and use this instead of shell for
your common tasks?

bwbasic - Bywater BASIC interpreter version 2.10
ftp://ftp.uu.net/usenet/comp.sources.misc/volume40/bwbasic/part[01-15]

-Brian