">" used in system() is not printing into file

I have a problem with the following skript in awk.

cat runde.txt |awk '{
                               if ($5==2) {
                                                   dataname_v=$1 "_" $4 "_adjust.rad
                                                   befehl1="gensurf seitenwand rollerblind1 '-0.95*s' '0.046' '2.85-$7*t' 1 1 > dataname_v"
                                                   system(befehl)
                                          }
                    }'

It is supposed to create in Radiance a surface with different parameters and then print it into the next course $1 "_" $4 "_adjust.rad-file automaticly. (It is getting $1, $4 and $7 from runde.txt, that is just a table-file with numbers).

The problem is that on one side it is performing the gensurf-command, but still it is just printing out the result on screen and it is also creating the files automatically with the right name, but they are empty.

Does anyone has an idea how to solve it? Maybe connecting strings? I have no idea.

Thanks a lot,
Sandra

A couple of trivial things to take care of -

cat runde.txt | awk '{ if ($5==2) {
                         dataname_v=$1"_"$4"_adjust.rad"
                         befeh="gensurf seitenwand rollerblind1 '-0.95*s' '0.046' '2.85-$7*t' 1 1 > "dataname_v
                         system(befeh)
                       }
                     }'

tyler_durden

but this isn't working as well.

I tried a lot of things. Your version is just outputting the following error:

Z`SYS(s,t)=2.85-*t;
> ^ unexpected character

befehl1="gensurf seitenwand rollerblind1 '-0.95*s' '0.046' '2.85-$7*t' 1 1 > dataname_v"

Error:
Z`SYS(s,t)=2.85-*t;
> ^ unexpected character

befehl1="gensurf seitenwand rollerblind1 '-0.95*s' '0.046' '2.85-$7*t' 1 1" ">" dataname_v

Error:
Usage: c:\Daysim\bin_windows\gensurf.exe material name x(s,t) y(s,t) z(s,t) m n [-s][-e expr][-f file]

befehl1="gensurf seitenwand rollerblind1 '-0.95*s' '0.046' '2.85-'" $7 "'*t' 1 1 >" dataname_v

Is just printing "# c:\Daysim\bin_windows\gensurf.exe seitenwand rollerblind1 -0.95s 0.046 2.85-0t 1 1" into the files

But none of this is performing the command and printing the result into the files.

Please, is there anyone who has an idea, how to solve this. Mabe I am just blind for it...

Try to escape the meta characters:

befehl="gensurf seitenwand rollerblind1 '\''-0.95\\*s'\'' '\''0.046'\'' '\''2.85-\\$7\\*t'\'' 1 1 \\> "dataname_v

Thanks a lot for your answer Franklin52. That is exactly what I was searching for. Unfortunately it is still not working. Is it maybe possible to explain how '/' and // ar working? I cannot find anythin in my books or internet for escaping metacharacters in shell. I just found something about execve(), but this is not defined on my system.

Secondly I tried already something with &, / and +, but I didn't get anywhere. I know that this is very special. I just want to automate my evaluation and am actually dying at this point.

Again thanks for your answer,
Sandra

Note that a backslash \ is used to escape the characters, not a slash /.

Regards

thanks a lot for your answer again Franklin52.

I think it is not possible what I want to do because of responding to a variable in system(). Do you know wether there are other possibilities responding a variable ($7) or connecting the strings between $7. Because this one worked already with printing the whole true command into the files:

befehl1="gensurf seitenwand rollerblind1 '-0.95*s' '0.046' '2.85-'" $7 "'*t' 1 1 >" dataname_v

Or do you think it is possible to pipe the result of this into another variable and then using it in a second system()-command?

Thanks a lot. Regards, Sandra

Is $7 a shell or an awk variable?

Regards

it is an awk variable, I think. Actually a good question.

I am piping every number in column 7 of runde.txt to awk to use it for befehl1.
(So because gensurf is supposed to create a surface I'll get in the end for example ten different surfaces created and saved into ten different files if I have ten different numbers a line in column 7 - thats my goal)

Why?

Regards

Don't escape $7 in that case:

befehl="gensurf seitenwand rollerblind1 '\''-0.95\\*s'\'' '\''0.046'\'' '\''2.85-" $7 "\\*t'\'' 1 1 \\> "dataname_v

thanks. Exactly, I don't want to escape $7.

But dealing with the command like this system() is not able to perform the command. Because it is not able to connect the first part before $7 ("gensurf...") with the second one ("\\*t'\'' 1 1 \\> ").Thats the problem.

And if I dont' just put " before and behind $7 it is telling me that there is an unexpected character (the $-sign). and i even don't think that system would interpretate it anymore as a variable.

That is actually the reason I was asking you for connecting the both strings (before and behind $7)? Or piping it somewhere else and then using it...

Do you get the right shell command with this command?

awk '{
  if ($5==2) {
    befehl="gensurf seitenwand rollerblind1 '\''-0.95\\*s'\'' '\''0.046'\'' '\''2.85-" $7 "\\*t'\'' 1 1 \\> " $1 "_" $4 "_adjust.rad"
    print befehl
  }
}' runde .txt

no just empty space...

Strange.. can you post the content of runde.txt between code tags.

of course:

nr blickr zeit system raum jal_hoehe_vorher jal_winkel_vorher jal_hoehe_nachher jal_winkel_nachher /rol_A_vorher rol_B_vorher rol_C_vorher rol_A_nachher rol_B_nachher rol_C_nachher
201 diagonal afternoon J1 1 L 0 30 0,94 40
201 diagonal afternoon R1 2 L 0 0 0 0,78 0,78 1,04
201 diagonal afternoon J2 1 L 0 0 1,11 42
201 diagonal afternoon R2 2 L 0 0 0 1,7 1,33 1,29
202 diagonal afternoon J2 1 R 0 0 0 42
202 diagonal afternoon R2 2 R 0 0 0 2,91 0 0,78
202 diagonal afternoon J1 1 R 0 36 0 36
202 diagonal afternoon R1 2 R 0 0 0 2,91 0,78 0,78
203 diagonal morning J1 1 L 0 60 0 35
203 diagonal morning R1 2 L 0 0 0 1,62 1,62 2,06
203 diagonal morning R2 2 L 0 0 0 1,67 1,66 2,01
203 diagonal morning J2 1 L 0 60 0 0
204 diagonal morning J2 1 R 0 60 0,33 17
204 diagonal morning R2 2 R 0 0 0 2,11 1,24 1,7
204 diagonal morning R1 2 R 0 0 0 2,11 0,82 1,47
204 diagonal morning J1 1 R 0 60 0 52

This is what I get, so I don't understand why you didn't get any output:

$ cat runde.txt
nr blickr zeit system raum jal_hoehe_vorher jal_winkel_vorher jal_hoehe_nachher jal_winkel_nachher /rol_A_vorher rol_B_vorher rol_C_vorher rol_A_nachher rol_B_nachher rol_C_nachher
201 diagonal afternoon J1 1 L 0 30 0,94 40
201 diagonal afternoon R1 2 L 0 0 0 0,78 0,78 1,04
201 diagonal afternoon J2 1 L 0 0 1,11 42
201 diagonal afternoon R2 2 L 0 0 0 1,7 1,33 1,29
202 diagonal afternoon J2 1 R 0 0 0 42
202 diagonal afternoon R2 2 R 0 0 0 2,91 0 0,78
202 diagonal afternoon J1 1 R 0 36 0 36
202 diagonal afternoon R1 2 R 0 0 0 2,91 0,78 0,78
203 diagonal morning J1 1 L 0 60 0 35
203 diagonal morning R1 2 L 0 0 0 1,62 1,62 2,06
203 diagonal morning R2 2 L 0 0 0 1,67 1,66 2,01
203 diagonal morning J2 1 L 0 60 0 0
204 diagonal morning J2 1 R 0 60 0,33 17
204 diagonal morning R2 2 R 0 0 0 2,11 1,24 1,7
204 diagonal morning R1 2 R 0 0 0 2,11 0,82 1,47
204 diagonal morning J1 1 R 0 60 0 52
$
$ awk '{
  if ($5==2) {
    befehl="gensurf seitenwand rollerblind1 '\''-0.95\\*s'\'' '\''0.046'\'' '\''2.85-" $7 "\\*t'\'' 1 1 \\> " $1 "_" $4 "_adjust.rad"
    print befehl
  }
}' runde.txt
gensurf seitenwand rollerblind1 '-0.95\*s' '0.046' '2.85-0\*t' 1 1 \> 201_R1_adjust.rad
gensurf seitenwand rollerblind1 '-0.95\*s' '0.046' '2.85-0\*t' 1 1 \> 201_R2_adjust.rad
gensurf seitenwand rollerblind1 '-0.95\*s' '0.046' '2.85-0\*t' 1 1 \> 202_R2_adjust.rad
gensurf seitenwand rollerblind1 '-0.95\*s' '0.046' '2.85-0\*t' 1 1 \> 202_R1_adjust.rad
gensurf seitenwand rollerblind1 '-0.95\*s' '0.046' '2.85-0\*t' 1 1 \> 203_R1_adjust.rad
gensurf seitenwand rollerblind1 '-0.95\*s' '0.046' '2.85-0\*t' 1 1 \> 203_R2_adjust.rad
gensurf seitenwand rollerblind1 '-0.95\*s' '0.046' '2.85-0\*t' 1 1 \> 204_R2_adjust.rad
gensurf seitenwand rollerblind1 '-0.95\*s' '0.046' '2.85-0\*t' 1 1 \> 204_R1_adjust.rad
$

Play around with the code to get the desired output.

Regards

Hey ho,

found the solution for it. the problem was still that even I was able to print it (thanks Franklin52) system() didn't work. Here is the solution:

$ cat runde.txt |awk -f test.awk

with test.awk:

{
s=sprintf("gensurf seitenwand rollerblind1 '-0.95*s' '0.046' '2.85- %1$s*t' 1 1 > %2$s_%3$s_adjust.rad\n", $7, $1, $4)
print "str", s
system(s)
}

[/COLOR]