I have a java (2.0) program with the following lines:
String cmdArray1[] = {"lp", "-d", "hp4m", "MyFile"};
System.out.prin tln(Runtime.get Runtime().exec( cmdArray1));
It compliles properly, but does not print the file to the printer. It
displays the following as the return from Runtime...:
java.lang.UNIXP rocess@1034bb5
It apparently is sending something out to bash and getting that result back.
This in within SuSE 8.2 Linux running bash.
The following line typed into the shell works properly:
lp -d hp4m MyFile
Anyone have any ideas?
Thanks, John 3 8257
First -- try using the full path for lp, i.e. "/usr/bin/lp" or similar
("which lp" should give you the full path). Interactive logins will set
a path potentially different from the path your "Runtime" call receives,
so Runtime may not have the path necessary to call just "lp".
-Matt
John Bowling wrote: I have a java (2.0) program with the following lines:
String cmdArray1[] = {"lp", "-d", "hp4m", "MyFile"}; System.out.prin tln(Runtime.get Runtime().exec( cmdArray1));
It compliles properly, but does not print the file to the printer. It displays the following as the return from Runtime...:
java.lang.UNIXP rocess@1034bb5
It apparently is sending something out to bash and getting that result back.
This in within SuSE 8.2 Linux running bash. The following line typed into the shell works properly: lp -d hp4m MyFile
Anyone have any ideas? Thanks, John
That solved the problem of printing the file.
If I specify the filename as "MyFile*", which could be handy when you have
multiple files that are similar but with a count, it will not find the file.
Currently I don't need to do that, but I probably will at some point.
Thanks, John
"Matt Smith" <ma********@uco nn.edu> wrote in message
news:3F******** ******@uconn.ed u... First -- try using the full path for lp, i.e. "/usr/bin/lp" or similar ("which lp" should give you the full path). Interactive logins will set a path potentially different from the path your "Runtime" call receives, so Runtime may not have the path necessary to call just "lp". -Matt
John Bowling wrote: I have a java (2.0) program with the following lines:
String cmdArray1[] = {"lp", "-d", "hp4m", "MyFile"}; System.out.prin tln(Runtime.get Runtime().exec( cmdArray1));
It compliles properly, but does not print the file to the printer. It displays the following as the return from Runtime...:
java.lang.UNIXP rocess@1034bb5
It apparently is sending something out to bash and getting that result
back. This in within SuSE 8.2 Linux running bash. The following line typed into the shell works properly: lp -d hp4m MyFile
Anyone have any ideas? Thanks, John
Wildcards are a shell function. I am not overly familiar with
"Runtime.ex ec", but my guess would be that the command is executed
directly by the system, not issued through a shell. If you really want
the shell features (like wildcarding), you may want to issue something
like this (with adjusted paths as needed):
"/bin/bash -c \"/usr/bin/lp -d hp4m MyFile*\" "
This forces the BASH shell to execute the command, and since the shell
is handling the command, shell functions like wildcards should work.
Note the escaped (\") quotes -- I believe (I may be wrong) that the -c
option for bash needs quotes around it's command string. Escape the
inner quotes with a backslash to make sure Java does not interpret them
as closing your string.
Hope that helps,
-Matt
John Bowling wrote: That solved the problem of printing the file. If I specify the filename as "MyFile*", which could be handy when you have multiple files that are similar but with a count, it will not find the file. Currently I don't need to do that, but I probably will at some point. Thanks, John
"Matt Smith" <ma********@uco nn.edu> wrote in message news:3F******** ******@uconn.ed u...
First -- try using the full path for lp, i.e. "/usr/bin/lp" or similar ("which lp" should give you the full path). Interactive logins will set a path potentially different from the path your "Runtime" call receives, so Runtime may not have the path necessary to call just "lp". -Matt
John Bowling wrote:
I have a java (2.0) program with the following lines:
String cmdArray1[] = {"lp", "-d", "hp4m", "MyFile"}; System.out.p rintln(Runtime. getRuntime().ex ec(cmdArray1));
It compliles properly, but does not print the file to the printer. It displays the following as the return from Runtime...:
java.lang.UN IXProcess@1034b b5
It apparently is sending something out to bash and getting that result back. This in within SuSE 8.2 Linux running bash. The following line typed into the shell works properly: lp -d hp4m MyFile
Anyone have any ideas? Thanks, John
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Hal Vaughan |
last post by:
I have a script used to find and run Java on a Windows system. It worked
fine on original tests (on a Windows XP system). It's now running on a
Windows 2000 (sp3) system, and it won't work -- the problem is this line:
set oCommand = WshShl.Exec(sCommand)
(it's about halfway down) Is there a problem with the Exec method in some
versions of VBS? Is the problem Windows version I'm on, or is it something
more obvious that I'm just not...
|
by: JW |
last post by:
Hi,
I don't seem to get any results from the following use
of Runtime.getRuntime().exec(cmd) using Java 1.4 on
Redhat linux.
Suppose that in the same directory as my java file below,
I have files junk1, junk2, junk3, and i want
to have the java program delete all of these files.
|
by: uwnewsgroup |
last post by:
When I was using Runtime.exec(String cmd) to run a unix utility (join), and
try to
get its standard output by using Process.getOutputStream(), it blocks
forever. I tried
it using Java 1.4 and the results are the same on SunOS 5.8, Redhat8.0,
cygwin.
I read relevant articles and find the reason is that the output of the
process exceeds the
buffer allocated for that process. So can I adjust the buffer size (on any
|
by: comp.lang.tcl |
last post by:
set php {<? print_r("Hello World"); ?>}
puts $php; # PRINTS OUT <? print_r("Hello World"); ?>
puts
When I try this within TCL I get the following error:
|
by: Gunnar G |
last post by:
If I wish to run an external application with exec(), does the execution of
the PHP script halt until the external application has finished?
| |
by: carl.dhalluin |
last post by:
Hello
I am completely puzzled why the following exec code does not work:
mycode = "import math\ndef f(y):\n print math.floor(y)\nf(3.14)"
def execute():
exec mycode
execute()
|
by: melmack3 |
last post by:
Hello
My PHP script executes many bash/cmd commands.
Functions like "exec()" or "system()" cause that new bash/cmd session
is started,
the command is executed and the session is closed. Unfortunately
it is very slow process so I would like to increase performance and
open one bash/cmd session on the begin of my script and execute
the commands such as in normal system opened bash/cmd window and close
it
|
by: territop |
last post by:
I am building an extended webbrowser which I want to support Optical Zooming as implemented in IE7. The control base uses the VS 2005 webbrowser native control with IOleCommandTarget COM interface implemented. Despite following MSDN docs on this it would appear that marshaling the pavIn and pavOut of the IOleCommandTarget.Exec does not correctly handle .Net objects for passing the zoom level. Based on several docs I have reviewed it would appear...
|
by: Maarten |
last post by:
Howdy,
Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and
I have a little problem with one function within my cd-management script.
For extracting a bit of info from my cd's I have an executable which I
execute with exec():
$discOutput = exec('./discid /dev/rdisk2');
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |