blob: 8e4094bab727713708ff1e27a8f69edd85bd0ebe [file] [log] [blame]
.TH SG_RAW "8" "April 2007" "sg3_utils\-1.24" SG3_UTILS
.SH NAME
sg_raw \- sends an arbitrary SCSI command (with an optional data phase) to a
device
.SH SYNOPSIS
.B sg_raw [\fIOPTIONS\fR] \fIDEVICE\fR CDB0 CDB1 ...
.SH DESCRIPTION
This utility sends an arbitrary SCSI command (between 6 and 16 bytes) to
the \fIDEVICE\fR. For the optional data phase, data can either be
read from a file and sent to the \fIDEVICE\fR or received from
the \fIDEVICE\fR and then displayed or written to a file.
.PP
The SCSI command may be between 6 and 16 bytes long. Each command byte is
specified in plain hex format (00..FF) without a prefix or suffix. See
EXAMPLES section below.
.PP
The commands pass through a generic SCSI interface which is implemented
for several operating systems including Linux, FreeBSD and Windows.
.SH OPTIONS
Arguments to long options are mandatory for short options as well.
.TP
\fB\-b\fR, \fB\-\-binary\fR
Dump data in binary form, even when writing to stdout.
.TP
\fB\-h\fR, \fB\-\-help\fR
Display usage information and exit.
.TP
\fB\-i\fR, \fB\-\-infile\fR=\fIIFILE\fR
Read data from \fIIFILE\fR instead of stdin. This option is ignored if
\fB\-\-send\fR is not specified.
.TP
\fB\-k\fR, \fB\-\-skip\fR=\fILEN\fR
Skip the first \fILEN\fR bytes of the input file or stream. This option
is ignored if \fB\-\-send\fR is not specified.
.TP
\fB\-n\fR, \fB\-\-nosense\fR
Don't display SCSI Sense information.
.TP
\fB\-o\fR, \fB\-\-outfile\fR=\fIOFILE\fR
Write data received from the \fIDEVICE\fR to \fIOFILE\fR. By default,
data is dumped in hex format to stdout. This option is ignored if
\fB\-\-request\fR is not specified.
.TP
\fB\-r\fR, \fB\-\-request\fR=\fIRLEN\fR
Expect to receive up to \fIRLEN\fR bytes of data from the \fIDEVICE\fR.
\fIRLEN\fR may be suffixed with 'k' to use kilobytes (1024 bytes) instead
of bytes. This option and \fB\-\-send\fR are mutually exclusive.
.TP
\fB\-s\fR, \fB\-\-send\fR=\fISLEN\fR
Read \fISLEN\fR bytes of data, either from stdin or from a file, and send
them to the \fIDEVICE\fR. This option and \fB\-\-request\fR are mutually
exclusive.
.TP
\fB\-t\fR, \fB\-\-timeout\fR=\fISEC\fR
Wait up to \fISEC\fR seconds for command completion (default: 20).
Note that if a command times out the operating system may start by
aborting the command and if that is unsuccessful it may attempt
to reset the device.
.TP
\fB\-v\fR, \fB\-\-verbose\fR
Increase level of verbosity. Can be used multiple times.
.TP
\fB\-V\fR, \fB\-\-version\fR
Display version and license information and exit.
.SH EXAMPLES
.TP
sg_raw /dev/scd0 1b 00 00 00 02 00
Eject the medium in CD drive /dev/scd0.
.TP
sg_raw \-r 1k /dev/sg0 12 00 00 00 60 00
Perform an INQUIRY on /dev/sg0 and dump the response data (up to
1024 bytes) to stdout.
.TP
sg_raw \-s 512 \-i i512.bin /dev/sda 3b 02 00 00 00 00 00 02 00 00
Showing an example of writing 512 bytes to a sector on a disk
is a little dangerous. Instead this example will read i512.bin (assumed
to be 512 bytes long) and use the SCSI WRITE BUFFER command to send
it to the "data" buffer (that is mode 2). This is a safe operation.
.TP
sg_raw \-r 512 \-o o512.bin /dev/sda 3c 02 00 00 00 00 00 02 00 00
This will use the SCSI READ BUFFER command to read 512 bytes from
the "data" buffer (i.e. mode 2) then write it to the o512.bin file.
When used in conjunction with the previous example, if both commands
work then 'cmp i512.bin o512.bin' should show a match.
.SH EXIT STATUS
The exit status of sg_raw is 0 when it is successful. Otherwise see
the sg3_utils(8) man page.
.SH AUTHOR
Written by Ingo van Lil
.SH "REPORTING BUGS"
Report bugs to <inguin at gmx dot de>.
.SH COPYRIGHT
Copyright \(co 2001\-2007 Ingo van Lil
.br
This software is distributed under the GPL version 2. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
.SH "SEE ALSO"
.B sg_opcodes sg_vpd(sg3_utils), hdparm(hdparm), sgdiag(scsirastools)