LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   extracting a .sh file - trap? (https://www.linuxquestions.org/questions/linux-software-2/extracting-a-sh-file-trap-480063/)

compu73rg33k 09-03-2006 01:25 PM

extracting a .sh file - trap?
 
First of all let me say I'm running Slackware 10.2. I'm trying to get some drivers for my Dell Photo Printer 720 and I've read it's just a repackaged Lexmark z600 series. Lexmark has some linux drivers for the z600 series but of course they're meant for RedHat systems. I extract the tar.gz and get a file called z600cups-1.0-1.gz.sh which the readme says is extracted by giving the command 'sh z600cups-1.0-1.gz.sh'. However when I run that command, I get
Code:

Verifying archive integrity...OK
Uncompressing Lexmark Printer Drivertrap: usage: trap [-lp] [arg signal_spec ...]

There seems to be a lack of documentation for trap becuase 'man trap' gives me no information nor has searching turned up much info. I'm still pretty clueless as to how the trap command even works and why it's related to executing this .sh. Once I get this file extracted, I have the rpms that I Can convert to .tgz and install and hopefully get this printer working!

zhangmaike 09-03-2006 02:10 PM

trap is a shell builtin, sometimes used in shell scripts (it's apparently used in this one). You can find documentation about it in the bash manpage. The trap command is used to trap certain signals such that they execute commands or parts of the script rather than their default action, such as stopping or ending the script. Here is an excerpt:
Code:

trap [-lp] [[arg] sigspec ...]
              The command arg is to  be  read  and  executed  when  the  shell
              receives  signal(s)  sigspec.  If arg is absent (and there is a
              single sigspec) or -, each specified  signal  is  reset  to  its
              original  disposition  (the  value  it  had upon entrance to the
              shell).

I can't imagine why a driver installer script would need to trap any signals of any kind.

EDIT: I just downloaded the driver myself to check the script out. Apparently, it's using trap to execute some cleanup of its temporary files from your /tmp directory. When the program is forcefully closed for any trappable reason, it will quickly erase its temporary files before exiting.

zhangmaike 09-03-2006 02:45 PM

Installing the Lexmark Z600 drivers on Slackware 10.2 (HOW-TO)
 
Download and extract the archive from the Lexmark site.

Run (as a NON-root user):
Code:

$ bash z600cups-1.0-1.gz.sh -keep
Using bash instead of sh will (for some reason) not kill the script when that trap usage problem is encountered. The script WILL exit with an error about the libtcl library (Slackware has a newer version), but because of the -keep option, the installer's files will be kept in /tmp and in ./installer

Now just cd into the installer directory, convert the z600*-cups.rpm to z600*-cups.tgz with rpm2tgz, and installpkg as root. Then, restart the CUPS scheduler and you're all set:
Code:

$ cd installer
$ rpm2tgz z600cups-1.0-1.i386.rpm
$ su
# installpkg z600cups-1.0-1.i386.tgz
# /etc/rc.d/rc.cups restart

You'll still have to configure your printer through the CUPS web-interface, of course, but at least the driver is installed.

It'd have been nice if Lexmark had simply included the driver file and instructions rather than a non-functional, distribution-specific GUI install.


All times are GMT -5. The time now is 04:19 PM.