[nflug] bash syntax problem

dan.colascione at gmail.com dan.colascione at gmail.com
Mon Aug 18 00:11:37 EDT 2008


Try running the script through bash -x.

-original message-
Subject: [nflug] bash syntax problem
From: Joe <josephj at main.nc.us>
Date: 08/18/2008 12:04 AM

Bash syntax often drives me batty.
I'm having a problem printing some digital camera pictures, so I wrote a
quick and dirty script to verify that the pictures I took to the photo
shop are the same as the ones that were on the camera flash card.
The script "chkpix" and it's output are below.

The problem is in the cmp command line which can't seem to find the
second file to compare.  The ls and md5sum commands find the file just
fine, so the path is OK.

When I run the cmp command by itself directly from the command line
(with no shell variables), it works fine.

I modified the script, eliminating the '\' at the end of the first cmp
argument and made the command one long line and it worked.

So, what's wrong with breaking up a long command line with one or more
escaped carriage returns?

Thanks.

Joe

chkpix:

#!/bin/bash
## compare two pictures for identity

cmp "/media/windoze/Documents and Settings/Owner/My
Documents/Images/Rita/Olympus/${1}" \ "/media/windoze/Documents and
Settings/Owner/My Documents/Images/Rita/Even Less Prints/${1}"
ls -l "/media/windoze/Documents and Settings/Owner/My
Documents/Images/Rita/Olympus/${1}"
ls -l "/media/windoze/Documents and Settings/Owner/My
Documents/Images/Rita/Even Less Prints/${1}"
md5sum -b "/media/windoze/Documents and Settings/Owner/My
Documents/Images/Rita/Olympus/${1}"
md5sum -b "/media/windoze/Documents and Settings/Owner/My
Documents/Images/Rita/Even Less Prints/${1}"


bigbird at sananda:~/bin$ bash chkpix P8063647.JPG
cmp:  "/media/windoze/Documents and Settings/Owner/My
Documents/Images/Rita/Even Less Prints/P8063647.JPG": No such file or
directory
-rwxrwxr-x 1 root ntfs-3g 634499 2008-08-06 17:10
/media/windoze/Documents and Settings/Owner/My
Documents/Images/Rita/Olympus/P8063647.JPG
-rwxrwxr-x 1 root ntfs-3g 634499 2008-08-16 22:05
/media/windoze/Documents and Settings/Owner/My
Documents/Images/Rita/Even Less Prints/P8063647.JPG
5a54b325abb196f4806edb5d7a4cbf2b */media/windoze/Documents and
Settings/Owner/My Documents/Images/Rita/Olympus/P8063647.JPG
5a54b325abb196f4806edb5d7a4cbf2b */media/windoze/Documents and
Settings/Owner/My Documents/Images/Rita/Even Less Prints/P8063647.JPG
bigbird at sananda:~/bin$

bigbird at sananda:~/bin$ cmp "/media/windoze/Documents and
Settings/Owner/My Documents/Images/Rita/Olympus/P8063647.JPG"
"/media/windoze/Documents and Settings/Owner/My
Documents/Images/Rita/Even Less Prints/P8063647.JPG"
bigbird at sananda:~/bin$

_______________________________________________
nflug mailing list
nflug at nflug.org
http://www.nflug.org/mailman/listinfo/nflug



More information about the nflug mailing list