Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 28th, 2006, 11:26 AM   #1
Pimp Daddy
Programmer
 
Join Date: Aug 2004
Location: Wherever the beautiful women are.
Posts: 30
Rep Power: 0 Pimp Daddy is on a distinguished road
Send a message via MSN to Pimp Daddy Send a message via Skype™ to Pimp Daddy
Counter

I have this bash script:

#! /bin/bash
# Script which shows how many Microsoft programs are 
# on the computer.

PTH="C:\Program Files"
cd $PTH
ls -1 | grep "Microsoft" | wc -l

exit

When I run it in Cygwin, I get this:

Quote:
$ ./Microsoft.sh
./Microsoft.sh: line 6: cd: C:\Program: No such file or directory
1
I understand why the one is there - when the first line fails it goes onto the other one and realises this script is the only one in the present directory with 'Microsoft' in the name. However, I don't know why the script is having such a problem with the space in the PTH variable.

I've tried putting a backslash before the space, removing the quotes and a combination of both.

Another thing is, when I do

cd "C:\Program Files"

or

cd C:\Program\ Files

on the command line, both work fine. According to what I did in the script they should have failed.

How can I fix this?
__________________
David Morris BSc.(Hons), MBCS
Qualified Computer Engineer
Administrator (SEED Software)
Pimp Daddy is offline   Reply With Quote
Old Aug 28th, 2006, 11:38 AM   #2
hush
Programmer
 
hush's Avatar
 
Join Date: Feb 2006
Location: 127.0.0.1
Posts: 35
Rep Power: 0 hush is on a distinguished road
When it calls the variable PTH it does not call it with the quotation marks as they are used to state that what is inside is a string.

Try putting another set of quotation marks inside the string.

I haven’t done scripting in a while and i got nothing to try it out on but that what it looks like from where I’m sitting.
hush is offline   Reply With Quote
Old Aug 29th, 2006, 7:38 PM   #3
a thing
Unverified User
 
a thing's Avatar
 
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0 a thing is on a distinguished road
Why is the variable even there? Why isn't it just cd "C:\Program Files".
__________________
Warning: My posts may change (dramatically) within the first 15 minutes they're posted.
Got 'Nux?—GNU/Linux and other free software support.
It's GNU/Linux, not just Linux.
a thing is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Counter Script Toro PHP 3 Jun 8th, 2006 12:01 AM
Process Id to Performance Counter Name coder0xff C++ 1 May 29th, 2006 11:19 AM
ASP Hit Counter raikkonen ASP 2 Nov 9th, 2005 5:51 AM
Web Counter Sane Python 9 Aug 8th, 2005 1:32 PM
Help with counter Supreme C++ 1 Jun 5th, 2005 10:29 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:26 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC