Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-Id: <5.1.0.14.2.20021020084313.02f91a40@pop3.cris.com> X-Sender: rrschulz AT pop3 DOT cris DOT com Date: Sun, 20 Oct 2002 08:55:53 -0700 To: cygwin AT cygwin DOT com From: Randall R Schulz Subject: Re: bash -c In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed G, At 08:37 2002-10-20, g frances wrote: >Hi, >I'm new to cygwin and have a simple question. Tried to find the answer on >the mailing list search archive, but no luck. I've just downloaded the >lastest version of Cygwin on Windows 2000 Professional, SP2. When trying >to invoke a command at the NT command prompt like the following: > >c:\cygwin\bin\bash -c "cp /testdir/test* /testdir2" > >This error occurs-- >cp: testdirtest*: The system cannot find the file specified. That diagnostic suggests that the command you really entered was this: c:\cygwin\bin\bash -c "cp \testdir\test* \testdir2" What you wrote above is (syntactically) correct. What I inferred you actually typed is not, since the backslashes are special in a POSIX environment and are not that realm's native file separator. Cygwin tolerates both Windows and POSIX file name syntaxes (including either forward or backward slashes), but that doesn't absolve you from quoting and escaping special characters such as backslash to keep them from having their special meaning to the Cygwin shell(s). I recommend you drop the CMD.exe environment and use the power of Cygwin and its POSIX / GNU Tools environment alone. You can still invoke non-Cygwin programs from Cygwin, you know. Likewise, you can also directly invoke Cygwin commands from CMD.exe, providing you have your local Cygwin bin directory in your Windows PATH. If you do that you can invoke Cygwin commands such as "cp" without the gyrations of using a shell with the "-c" option. (Be sure it's the Windows directory name: "C:\cygwin\bin" you add to the Windows PATH variable.) In this case, since BASH was able to execute "cp" without using an absolute name, I assume you've already done this. I'm not completely well-versed on this detail, but I'm under the impression that the interpretation of "*" is different when a Cygwin command is invoked directly from a Windows CMD.exe. (In a fully Cygwin context, the shell itself handles wildcard expansion, but Cygwin programs have special startup code that's activated when they're launched from a non-Cygwin parent process. That special startup code detects the presence of the wild-card character in the arguments and expands them as CMD.exe would). Chris F.: Please do write that book! Randall Schulz Mountain View, CA USA >But when invoking the same command by just typing within the cygwin shell, >it works. > >Thanks for your help. > >gfrancess -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/