Question

I have a script that I run from a Java GUI. It executes a SQL script and writes the results to a log file in the tmp directory. The rest of the script should open up an xterm and display the results of the output file to the screen. It creates the log file as supposed and it opens up an xterm as well. The only problem is that it freezes up after that point and I have to restart the whole process again. Here is an example of the script that I am using to open the xterm

#!/bin/csh -f



#set MYSQL=${MYSQL_HOME}/mysql
set PSQL=${PSQL_HOME}/psql
set MORE=/usr/xpg4/bin/more


set REPORT=/h/Scripts/DataValidation/ParametersDataReport.sql


#${REPORT}

${PSQL} ${USER}<${REPORT} 

#Get the number of lines in the report file for scrollbar control
#set lc='wc -l /tmp/results.log'
#echo $lc

#Open an extra terminal

set title="EARTH ORIENTATION PARAMETERS REPORT"

/usr/openwin/bin/xterm -T "$title" \
-bg lightblue -fg black -sb -sl 2000 -ut -e ${MORE}  \
-f /h/USERS/Pablito/results.log     \

exit

MORE and title are defined as variables in the script file. Why is my script crashing and causing the terminal to hang up? Could this be a segmentation fault?

I am doing all this through an ssh connection. I looked at the command issued and this is what it states:

/usr/openwin/bin/xterm -sb -ls -display@d&@;

I typed this command on the terminal and it displayed the results pretty well. Why can't I do this from the GUI?

/usr/openwin/bin/xterm -T EARTHORIENTATIONPARAMETER -geometry 104x50+0+80 -bg lightblue -fg black -sb -sl 2000 -ut -e /usr/xpg4/bin/more -f /tmp/results.log

When I try to use the GUI it just freezes up on me (meaning I cannot access the GUI or the terminal). It also contains an error

bg: Command not found

on the terminal where the GUI was launched.

I guess what I really should be asking is how to I execute the following command in a csh script because when I type it manually from the terminal it produces the desired effect

xterm -T "EarthOrientation Parameter" -geom 104x50+0+80 -bg pink -fg black -sb -sl   2000 -ut -e /usr/xpg4/bin/more -f /h/USERS/local/Pablito/results.log
Était-ce utile?

La solution

I'll assume that the version of the script in your question matches the one you're actually running.

/usr/openwin/bin/xterm \
-title "$title"        \ 
-geometry 100x40+0+90
-bg lightblue -fg brown \
-sb -sl 2000 -ut
-e ${MORE} -F /tmp/results.log

If you're going to invoke this as a csh script, it needs a #!/bin/csh -f at the top, or you need to invoke it explicitly as csh -f script-name.

You're missing a couple of backslashes. Since there's no \ on the -geometry line, the lines following that are not passed as arguments to the xterm command. The code you've shown us is equivalent to:

/usr/openwin/bin/xterm -title "$title" -geometry 100x40+0+90
-geometry 100x40+0+90 -bg lightblue -fg brown sb -sl 2000 -ut 
-e ${MORE} -F /tmp/results.log

This should invoke xterm with no command specified, so it will run your default shell interactively. The following lines should produce error messages:

-geometry: Command not found.
-e: Command not found.

but if you're invoking the script from a GUI you likely wouldn't see those messages.

Adding \ characters at the end of the geometry and -sb lines should solve that problem.

Since the script invokes xterm in the foreground (without a trailing & on the command), the script will wait for the xterm window to close before terminating.

You say it "freezes up"; I'm not sure what you mean by that, but whatever happens after the xterm closes and the script terminates is going to be controlled by your Java GUI code, which you haven't shown us.

Again, I'm assuming that those backslashes are missing in the script you're actually running. If not, you need to update your question, showing us the exact script you're running.

UPDATE :

Apparently my assumption was incorrect; your actual script is quite different from one that originally appeared in your question.

I cannot emphasize strongly enough how important it is to copy-and-paste the exact script or program that is causing the problem, or a modified version of it that you've confirmed causes the same problem. If you try to post an approximation of the script, you're very likely to omit the code that causes the problem.

http://sscce.org/ discusses this, but the site appears to be down at the moment; the Google cache is here.

So here's the relevant portion of the script that's now in your question:

/usr/openwin/bin/xterm -T "$title" \
-bg lightblue -fg black -sb -sl 2000 -ut -e ${MORE}  \
-f /h/USERS/Pablito/results.log     \

exit

In a comment, you've said that you're getting an error something like

-bg Command is not found

That should really be in the question, since it's critical information for anyone trying to answer it.

(I suspect it's really -bg: Command not found.; again, exact copy-and-paste is as important for error messages as it is for code.)

I think the problem now is that you have a space after the backslash on the xterm line. A \ line continuation character must be at the very end of a line. If there's a space after the backslash, it's not treated as continuation character, and the next line will be treated as a separate command.

And the \ on the last line of your command is useless and potentially dangerous. It joins that line with the following line, which is empty and therefore probably harmless, but if you deleted that blank line it would pass the word exit as an argument to xterm.

The simplest workaround would be to modify your script so that the entire command is on one (very long) line with no backslashes.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top