PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > any comments on my gnuplot-script?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

any comments on my gnuplot-script?

Réponse
 
LinkBack Outils de la discussion
Vieux 06/12/2006, 22h05   #1
Martin Jørgensen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut any comments on my gnuplot-script?

Hi,

Consider this:
--------
cat make_graphs
echo "Creating 2D-plots at each timestep"

for file in splot*.txt;
do echo "splot \"$file\" w lines" > temp.txt;
gnuplot plot_header.txt temp.txt
epstopdf gnuplot.eps
echo Making ${file%.txt}.pdf
mv gnuplot.pdf ${file%.txt}.pdf
done

echo
echo "Creating temperature profile"
gnuplot plot_commands.txt
epstopdf gnuplot.eps

echo
echo "Deleting temp-files"
rm temp.txt
rm gnuplot.eps
--------

I made that, but I'm not very experienced, so for instance
this line:

do echo "splot \"$file\" w lines" > temp.txt;

Is that the right method? The \" comes from my c-programming habits. It
looks like it works in bash too... Sometimes I see you guys discuss
something about:

What if $file has a space in it? Will it work too? I'm also writing to
temp.txt in each run... Perhaps I can avoid that?

I was pretty lucky about the:

echo Making ${file%.txt}.pdf

Because I remember I had seen something like that once... Could somebody
please remind me: If I wanted to remove the first part of the file,
(until the .txt part) how is it you do that? I forgot it...


Best regards
Martin Jørgensen

--
---------------------------------------------------------------------------
Home of Martin Jørgensen - http://www.martinjoergensen.dk
  Réponse avec citation
Vieux 06/12/2006, 23h44   #2
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: any comments on my gnuplot-script?

2006-12-06, 23:05(+01), Martin Jørgensen:
> Hi,
>
> Consider this:
> --------
> cat make_graphs
> echo "Creating 2D-plots at each timestep"
>
> for file in splot*.txt;
> do echo "splot \"$file\" w lines" > temp.txt;
> gnuplot plot_header.txt temp.txt
> epstopdf gnuplot.eps
> echo Making ${file%.txt}.pdf
> mv gnuplot.pdf ${file%.txt}.pdf
> done


for file in splot*.txt
do
printf 'split "%s" w lines\n' "$file" |
cat plot_header.txt - |
gnuplot &&
printf 'Making "%s"\n' "${file%.txt}pdf" &&
epstopdf --outfile="${file%txt}pdf" gnuplot.eps
done

[...]
> do echo "splot \"$file\" w lines" > temp.txt;
>
> Is that the right method? The \" comes from my c-programming habits. It
> looks like it works in bash too... Sometimes I see you guys discuss
> something about:


That's allright except for your usage of echo which is a
non-portable non-reliable commande.

> What if $file has a space in it? Will it work too?


If you qupte variables yes. Depending on the syntax of gnuplot,
you'll probably have troubles for files whose name contains ", \
or newline characters (because of the split "$file").

> I'm also writing to
> temp.txt in each run... Perhaps I can avoid that?


Yes.

> I was pretty lucky about the:
>
> echo Making ${file%.txt}.pdf


you need to quote any ${...}

echo "Making ${file%.txt}.pdf"

> Because I remember I had seen something like that once... Could somebody
> please remind me: If I wanted to remove the first part of the file,
> (until the .txt part) how is it you do that? I forgot it...


That would be in your shell manual. ${file##*.} would delete up
to the "."

--
Stéphane
  Réponse avec citation
Vieux 07/12/2006, 06h11   #3
Martin Jørgensen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: any comments on my gnuplot-script?

Stephane CHAZELAS <this.address@is.invalid> writes:

> 2006-12-06, 23:05(+01), Martin Jørgensen:
>> Hi,
>>
>> Consider this:
>> --------
>> cat make_graphs
>> echo "Creating 2D-plots at each timestep"
>>
>> for file in splot*.txt;
>> do echo "splot \"$file\" w lines" > temp.txt;
>> gnuplot plot_header.txt temp.txt
>> epstopdf gnuplot.eps
>> echo Making ${file%.txt}.pdf
>> mv gnuplot.pdf ${file%.txt}.pdf
>> done

>
> for file in splot*.txt
> do
> printf 'split "%s" w lines\n' "$file" |
> cat plot_header.txt - |
> gnuplot &&
> printf 'Making "%s"\n' "${file%.txt}pdf" &&
> epstopdf --outfile="${file%txt}pdf" gnuplot.eps
> done
>
> [...]


Aha... Thanks. But the file-name is not inserted correctly (I assume you
meant splot instead of split?):

---
$ ./make_graphs
Creating 2D-plots at each timestep

gnuplot> splot "splot*.txt" w lines
^
can't read data file "splot*.txt"
line 0: util.c: No such file or directory


Creating temperature profile

gnuplot> splot "gnuplot.txt" with lines
^
can't read data file "gnuplot.txt"
"plot_commands.txt", line 15: util.c: No such file or directory

==> Warning: BoundingBox not found!

Deleting temp-files
---

So it obviously inserted file "splot*.txt" but I think the program can
only handle 1 file at a time: splot000.txt, splot001.txt, splot 002.txt,
etc. in order...

>> Is that the right method? The \" comes from my c-programming habits. It
>> looks like it works in bash too... Sometimes I see you guys discuss
>> something about:

>
> That's allright except for your usage of echo which is a
> non-portable non-reliable commande.


Thanks.

>> What if $file has a space in it? Will it work too?

>
> If you qupte variables yes. Depending on the syntax of gnuplot,
> you'll probably have troubles for files whose name contains ", \
> or newline characters (because of the split "$file").


Can a file contain a newline character? Really? Ok, but that is not a
problem though, because I choose the filenames myself. Only to learn I
bit more, I asked...

>> I'm also writing to
>> temp.txt in each run... Perhaps I can avoid that?

>
> Yes.
>
>> I was pretty lucky about the:
>>
>> echo Making ${file%.txt}.pdf

>
> you need to quote any ${...}


Ok.

> echo "Making ${file%.txt}.pdf"
>
>> Because I remember I had seen something like that once... Could somebody
>> please remind me: If I wanted to remove the first part of the file,
>> (until the .txt part) how is it you do that? I forgot it...

>
> That would be in your shell manual. ${file##*.} would delete up
> to the "."


Thanks...


Best regards
Martin Jørgensen

--
---------------------------------------------------------------------------
Home of Martin Jørgensen - http://www.martinjoergensen.dk
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 13h42.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11511 seconds with 11 queries