Sgt. John Seifert

Greenhorn
+ Follow
since Nov 13, 2001
Merit badge: grant badges
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
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 Sgt. John Seifert

fyi,
the path can be found at a unix prompt by typing
which basename
or
which <whatever you are trying to find.>
21 years ago
actually I solved the problem.
for the benifit of others,
the solution i came up with was to specify the full path to the script variables that it could not find.
for example: it could not find 'basename'
so in my script i replaced 'basename' with 'usr/bin/basename'
what happens is that sometimes the environment is not loaded as it should be so paths to these special reserved functions can not be found, therefore specifying the full path will correct the problem.
hope this can help others, this one was a real pain
21 years ago
hi,
i am having a similiar problem and was wondering if you got this to work.
John
21 years ago
Hi,
I am having trouble executing the following shell script using Runtime.exec()
<code>
#!/bin/ksh
. /sideshow/environment/directories.sh
ROOT=/sideshow/java/scripts/
COMMAND_FILE=${ROOT}commands.IBX.RAW.CRC
cd ${ROOT}
rm -f $COMMAND_FILE
print "Send the command '"$*"' to the inbox"
echo $* >> $COMMAND_FILE
uuencode $COMMAND_FILE `basename $COMMAND_FILE` | mailx <target email address>
</code>
The syntax I use for Runtime.exec is :
<code>
String cmd[] =
{"/bin/ksh",
"-c",
"/sideshow/java/scripts/send.command.sh"};
Process p = Runtime.getRuntime().exec (cmd);
try { p.waitFor(); } catch (Exception e) {e.printStackTrace();}
</code>
The error I am recieving from the output is:
<code>
send.command.sh[2]: basename: not found.
send.command.sh[21]: rm: not found.
send.command.sh[26]: basename: not found.
send.command.sh[26]: mailx: not found.
send.command.sh[26]: uuencode: not found.
</code>
This script work fine from a UNIX command line but doesn't work using Runtime.exec(). Any help is greatly appreciated.
Thanks
John
21 years ago
actually i put the <code>open()</code> call in write because i was having a problem with the stream closing. it was sort of a work around to the already existing problem. Typically i would write a 1000 or so lines to a file without closing or re-opening the stream.
21 years ago
Hi all,
I am having problems with the class defined below. The output stream is being closed with out me closing it. It happens when I go to write something out. I have now added code to open the stream before I write even if the stream is thought to be open and it still is closed sometimes. Here is the class below. Any help is greatly appreciated.
<code>
public class FileOutputWriter
{
// The PrintWriter for writing to text files
private BufferedWriter bufferedWriter = null;
private FileWriter fileWriter = null;
// The OutputState of this object
private OutputWriterState state = null;
PrintWriter out = null;
boolean streamIsOpen = false;
String outputTarget = null;
public FileOutputWriter(String outputTarget)
{
this.outputTarget = outputTarget;
}

synchronized public boolean open()
throws IOException
{
boolean append = false;
// Check the state of this object
if (!state.equals(OutputWriterState.NEW))
append = true;

File fout = new File (outputTarget);

fileWriter
= new FileWriter (fout.getAbsolutePath(), append);
bufferedWriter = new BufferedWriter (fileWriter);
out = new PrintWriter (bufferedWriter);
streamIsOpen = true;
return true;
}
synchronized public void close()
throws IOException
{
streamIsOpen = false;
bufferedWriter.close();
out.close();
fileWriter.close();
}

synchronized public boolean write(String rec)
throws IOException
{
open();
out.print (rec);
out.flush (rec);
}
} // class
</code>
Please help. This is driving me nuts!
21 years ago