Scripiting quote and variable issues

Hello all I have an interesting problem here that I can't seem to figure out. Note this exists inside a script with the following header: m#!/usr/bin/sh

What I am trying to do is build an automounting script for USB hdd's, the idea is that the user plugs their drive in then runs the script. The script looks at dmesg and seaches for the lines that contain the drive information. From those lines I pull what USB location the drive is attached to, this is where I am having an issue:

 
 
rsh . -l int "autosu - root -c 'dmesg |grep pci@ |head -1 | cut -d/ -f 4 |cut -d' ' -f 1'"
 

The problem as far as I can figure is that I have single quotes inside of single quotes (inner marked in red), if I remove that cut statement I get exactly what I expect with the extra stuff on the back end I need to cut off; otherwise it brings in the entire line ignoring both cut statements.

In addition I am also trying to assign that to a variable inside the script something along the lines of this:

 
USBL='rsh . -l int "autosu - root -c 'dmesg |grep pci@ |head -1 | cut -d/ -f 4 |cut -d' ' -f 1' " '
 

Can anyone help me ....

Sometimes with rsh/ssh/ssh2, I go with this style, which is more easily inspected before execution:

echo " . . ." | rsh there ksh

DGPickett,

For reference ./animals looks like the following

cat,tiger,Fluffy
sheep,blackSheep,Spike
ect....

Am I to understand that placing a command such as this:

echo"grep cat ./animals"

will print the output of that command to the screen, so in this example I would get:
cat,tiger,Fluffy on the screen ?

Which Operating System and version are you running?

Hard to follow a script which has a problem.
Can you post a sequence of commands which when typed at a keyboard output the value required?

Dodgy syntax. Is it safe to assume that the period is just the target hostname blanked out? Is the "dmesg" command to be executed on a remote computer?

This might work:

rsh server -l int autosu - root -c "dmesg |grep pci@ |head -1 | cut -d/ -f 4 |cut -d' ' -f 1"

Well, yes, like this:

echo"grep cat ./animals" | rsh animal_host ksh

Essentially, you are generating a script dynamically, sending it over to the host for ksh to run. Don't forget something like ". ./.profile" if you need snvironment. I favor single quotes unless I want variable expansion, as they have fewer metacharacters. Parens are very nice for this, as you can mix in all sorts of commands, and as always, you can preview the created script for validity:

(
  echo '. ./.profile'
  echo 'grep cat ./animals'
 ) | rsh animal_host ksh