Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Bash / Shell Scripting (http://www.programmingforums.org/forum26.html)
-   -   Help Me!! (http://www.programmingforums.org/showthread.php?t=2280)

magyarkid Feb 15th, 2005 6:12 PM

Help Me!!
 
HEEELLLLPPPP!!!!
I've been developing a basic suite of apps to get to know Shell Scripting in Fedora 1 Linux. I have 2 applications done and bug-free, but my third is no... here is the code:
:

#-------------Credits------------
# (C) 2005 Kid Kompany
# Written by Chris Szentkiralyi
# v1.5
#--------------------------------
#!/bin/sh

makeDir() {
        if mkdir "_$dir"
        then
                echo "Directory _$dir created..."
        else
                echo "ERROR: Directory could not be created"
        fi
}
changeDir() {
        if cd "_$dir"
        then
                echo "Directory changed to $dir"
        else
                ECHO "ERROR: Directory could not be changed"
        fi
}
copyFiles() {
        if cp *.* _$dir
        then
                echo "Files copied to _$dir"
        else
                echo "ERROR: Could not copy files to _$dir"
        fi
}
read dir
makeDir
changeDir
copyFiles

The problem is that I can't seem to get the copyFiles() function to work right. It won't let me use '*.*' to copy all of the files... and I am out of ideas. PLEASE HELP!!!

big_k105 Feb 15th, 2005 6:40 PM

just try a * and not *.* not all files in linux have a ext so just do the * :)

magyarkid Feb 16th, 2005 6:43 AM

Oh... but this is an all-perpouse utitlity... so what happens if it ran into, say, 'file.ext'? Would the * work for that? Or would it have to be *.*?

Ooble Feb 16th, 2005 8:20 AM

It works whether or not the file has an extension. Go for it.

magyarkid Feb 17th, 2005 6:36 AM

OK. Thanks, Ooble and big_k105!

NOTE: I can't edit my first post to add [solved]... the EDIT buttons are on my other posts, but not the first one...

magyarkid Feb 17th, 2005 3:33 PM

Arggggg
 
Great.... the files were copied... and it works. But it still gives me this:
:

cp: cannot stat `*': No such file or directory
Like I said... the utility works, but an error is still displayed.


All times are GMT -5. The time now is 9:39 PM.

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