[Gambas-user] How to sent a line line to a lp1 printer and form to lp0 printer directly.
Demosthenes Koptsis
demosthenesk at ...626...
Thu Sep 24 13:45:55 CEST 2009
On Thu, Sep 24, 2009 at 2:12 PM, Vassilis K <vkan53 at ...2300...> wrote:
> Thank you all for your help.
>
> I have tried the following printing SUB:
>
> PUBLIC SUB bEktiposi_Click()
> DIM hPrinter AS Printer
> DIM hFile AS File
> hPrinter = OPEN "dev/lp1" FOR OUTPUT
> hPrinter.EndOfLine = gb.Windows
> PRINT #hFile, "test a line: ";
> CLOSE hPrinter
> END
>
> It is compiled but it stops when bEtiposi Button is clicked
> at line :
> hPrinter = OPEN "dev/lp1" FOR OUTPUT
> with the message:
> " Access Forbidden. "
>
> I have tried to print from terminal with commands
> echo -e "Hello World\r" > /dev/lp1
> cat /etc/passwd > /dev/lp1
> They have both worked only with root terminal.
>
> First question:
> How exactly can I put echo into SHELL command of Gambas?
an example of: echo "This is a test" >> /var/log/messages
DIM varCommand AS String
DIM varProcess AS Process
varCommand = "echo \"This is a test\" >> /var/log/messages"
varProcess = SHELL varCommand WAIT
but you need root privileges to write to /var/log/messages
> Second question:
> I suppose that's the reason why the routine OPEN "dev/lp1" .... is not
> working. It needs root privileges!
> Is there any other way to setup the printer /dev/lp1 in order to work with
> simple user privileges?
users can use the command lpr to send files for printing
see manual of lpr with man lpr
also the command
echo "This is a test" > /dev/lp0
is the same with
echo "This is a test" | lpr
or
echo "This is a test" | lpr -P PrinterName
where PrinterName is your printer's name
May be you must use lpr instead sending strings/files to /dev/lp0 directly
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry® Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9-12, 2009. Register now!
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
--
Γεια χαρα σε όλους!!!
Regards,
Demosthenes Koptsis
More information about the User
mailing list