Win a copy of Terraform in Action this week in the Cloud forum!

Simon Ingram

Ranch Hand
+ Follow
since Nov 30, 2003
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Simon Ingram

Thanks for trying Tim,

Alas I'm just getting an additional error message:

/Users/simoningram/unix/bin/linear_search_old.ksh[64]: printf: -f: unknown option
/Users/simoningram/unix/bin/linear_search_old.ksh[64]: printf: -- j: unknown option
Usage: printf [ options ] format [string ...]

The odd thing is I have used the printf in the way described. Sometimes it works sometimes it doesn't.
I'm beginning to think the answer to my first question is simply - yes!

Best Regards
Simon
7 years ago
Hi guys,

I just want to confirm whether OS X 10.9.3 really is a bit of a pigs breakfast.
I have the following code (Korn shell)

typeset -i j=0
#
while (( j <= count ))
do
printf "-- j = %d\n" $j
if [ ${arrayA[j]} == $search_value ]
then
answer=$(( $j + 1 ))
# answer=$j
printf "answer = %d\n" $answer
# exit 0
fi
(( j = j + 1 ))
done
#

I'm getting the following error: (the loop has 28 entries).

answer = 28
/Users/simoningram/unix/bin/linear_search_old.ksh[63]: printf: -- j: unknown option
Usage: printf [ options ] format [string ...]
/Users/simoningram/unix/bin/linear_search_old.ksh[64]: [: argument expected
29
answer = 28

I am concerned about the "printf unknown option" error, since IMHO there is nothing wrong with the syntax (the second printf is ok)

This just shows details about the installation:
/Users/simoningram/unix/bin => uname -a
Darwin Simons-iMac.local 13.2.0 Darwin Kernel Version 13.2.0: Thu Apr 17 23:03:13 PDT 2014; root:xnu-2422.100.13~1/RELEASE_X86_64 x86_64

I have seen posts about printf not working with find, but this is just the standard shell command.
I'm going a bit blind on this one. Am I missing something?
7 years ago
Mavericks didn't make any difference.
The strange thing is that I ran this script on my Mac at home and on our unix system at work and in both cases it fails. I will investigate this at work with our specialists, but it is very good to know that you have managed to get the script working on your system, so thanks Ulf.
7 years ago
Hi Ulf,

I haven't installed Mavericks. Maybe I should do that?
7 years ago
Hi Ulf,

many thanks for your persistence. Here is my program: trig_test.ksh

#!/bin/ksh
(( d = sin(1.0) ))
echo $d

/Users/simoningram/unix/bin => trig_test.ksh
/Users/simoningram/unix/bin/trig_test.ksh: line 3: d = sin(1.0) : arithmetic syntax error

I too have used google and tried all the different syntax variations, but this problem is more fundamental, as I suggested in my first post.

Best Regards
Simon

7 years ago
You are right, there are many ways to get the job done, but I am interested in the Korn shell and what it can do. I have a book on the shell, that tells me it can do trig functions and when I put in an example from the book, I get an error. It's kind of exasperating! I just wonder what I'm doing wrong.
7 years ago
Hi Ulf,

thanks for the reply. You are partially correct, if I had tried to execute the sine function within bc then it would be "s" not "sin". But in the script the bracket after EOF (line 5) terminates the bc command and everything following is executed in the shell. The sine command in the korn shell is "sin" not "s".

In fact we can ignore the bc altogether and just try to execute the sin command in the shell hardcoding the argument. I can't get it to work! Arithmetic syntax error.

Best Regards
7 years ago
Hi folks,

I have read that the Korn Shell has built in Trig functions like sine and cosine. Imagine my disappointment when I get an unknown function message.
I am running on a MAC with OS X. It has a Korn shell, but I don't know if its ksh 88 or ksh 93. There should be a way of interrogating the system for this info, but I don’t know how.
I tried uname –a but it didn’t help. I would be very surprised if I am using the old Korn which raises the question: why don’t the trig functions work?

Here’s my test script:

#!/bin/ksh
##
val=$( bc -l <<EOF
a(1) # arctan 1 is 45 degrees
EOF)
##
echo $val
#
## shell trig functions
sin45=$(( sin($val) ))
echo $sin45

When I run it:

$ ksh simon_bc
.78539816339744830961
simon_bc[10]: sin(.78539816339744830961) : unknown function

AM I missing something?

With thanks and Best Regards
Simon>
7 years ago
Hi Bear,

don't want to appear ungrateful, but is there any way to do it just using java (scriptlets). I know you will tell me tags are great and intuitive and marvellous for web designers. But... can it be done without the tags?
14 years ago
JSP
Hi Bear,

thanks for your patience! Yes, practically my first and obviously my lack of prowess is plain to see. So, sorry to keep banging on, but how does the jsp fill in the src attributes of the img tag?
14 years ago
JSP
Hi,

Sorry I am not making myself clear. At least we agree there is a butt simple solution to this, so let me try again:

If I have image files that contain playing cards Ac.jpg = ace clubs, 2c.jpg = two clubs etc

now I want to display a screen with some cards on it. My servelt can decide which cards to display and then forwards to a jsp. But when I write the jsp i don't know the cards, they are decided at run time and this is my problem. When I write the jsp the only way I know to display an image is to use the HTML <img> tag and for this I must specify an image file. But I don't know it!

that's my problem!
14 years ago
JSP
Thanks for the advise about how do design the app, but i am still in the concept stage and my question is a very simple one! If I want to display a page with a selection of images that are not known in advance and therefore cannot be coded in html

i.e.
<img src="path/file" etc

because the file name is not known, how is it done? do i specify a dummy file name and then create the file on the fly? or can I somehow dynamically create the html? I suppose I could use servlet println statements, but I feel sure the wickedly smart team would be very disappointed!

Come on, guys, I'm sure there is something simple that I am missing!
14 years ago
JSP
Hi there Bear and Ulf,

I am trying to construct a simple card game. The client plays the server, but I had in mind that the server would be controlling the game, so no javascript! The first step is to deal six cards to each player. The idea is to provide a page with six cards along the top (the server's cards) and six along the bottom (the client's cards). Now my page will display 12 image files called card1.jpg, card2.jpg etc. The first step is to randomly select 12 from 52 and then write the appropraite card to the page. So aceClubs.jpg goes to the card1.jpg position etc. How would I do this in a jsp? I can't hardcode (HTML) the pages until I know what the cards are and as I say, overwriting files via streams doesn't sound like the right way to do it either.

regards
Simon
14 years ago
JSP
Hi guys,

Sorry if I am not making myself clear. If I want to display an image on a page then I use the following HTML

<img src="path/image.jpg" width = "70" height="100" />

which will display the image called image.jpg located at directory path. Now if I want to display a second image in the same position on the page, i.e. overlay a second image, how do I do it?

the code in my former posts simply showed how I had failed. If I define an image, then I either have to generate an entirely new page with the second image in the same place or I can overwrite the content of the file at path/image.jpg. Neither seem very good options if I am trying to play cards. I was inviting the experts to suggest a solution.
14 years ago
JSP
Hi Ulf,

the logic is on the server. the problem is not making the decision, it is the technical matter of displaying different images on a web page. Imagine the page shows some playing cards (jpeg files). Is it possible to keep the table static and use the servlet to write different images (cards) to the same location on the page? I can't see how to get round the fact that the HTML is not flexible.
14 years ago