tags:

views:

261

answers:

4

I have attempted to run the following bash script on my internet tablet (Nokia N810 running on Maemo Linux). However, it doesn't seem that it is running, and I have no clue of what's wrong with this script (it runs on my Ubuntu system if I change the directories). It would be great to receive some feedback on this or similar experiences of this issue. Thanks.

WORKING="/home/user/.gpe"
SVNPATH="/media/mmc1/gpe/"

cp calendar categories contacts todo $WORKING
+1  A: 

The bash cp command can copy multiple sources to a single destination, if it's a directory.

Does the directory /home/user/.gpe exist?

Bear in mind that the leading dot in the name can make it hidden unless you use ls -a

I tried your commands in cygwin:

But I used .gpe instead of /home/user/.gpe

I did a touch calendar categories contacts todo to create the files.

It worked fine.

pavium
The working directory at that time is SVNPATH="/media/mmc1/gpe/", so no point trying SVNPATH. /home/user/.gpe does exist, but it's a hidden file.
stanigator
But for `cp` to work as you want, $WORKING has to be a directory. That is `cp file1 file2 file3 file4 directory`. If `.gpe` is a (hidden) file, it won't work.
pavium
Is there any way to make this work though? I want to make it work. Is there an easy way of making .gpe not a hidden dir?
stanigator
Remove the dot from the directory name (gpe), and it won't be hidden. And of course hidden files/directories are only hidden when you type `ls` *without* the `-a` option. Hidden files can be opened and written to like any other. It may take some fiddling to convince a file manager to display them, but they're nothing special. The dot is what's making it hidden.
pavium
What if the .gpe directory is created and used by another external application, which is why I'm reluctant to rename it in the first place?
stanigator
If that's possible, I suppose you don't want to rename it. Maybe create another directory called `gpe` and try it out. You can always check the contents of `.gpe` and the modification dates of the files in it, as you use other applications. That way you can get an idea if anything is likely to use it. Bear in mind what I said, though, *there's nothing special about a hidden file or directory* you can still create it, write to it, open it. If `.gpe` exists *but it's a file* your bash script won't work. It worked in Ubuntu *because you changed the directories*, probably to something visible.
pavium
Just checked the application just accesses the .gpe copy regardless of the naming convention.
stanigator
+1  A: 

What actually happens when you run your script? It's helpful if you include details of error messages or behavior that differs from what's expected and in what way.

If $WORKING contains the name of a directory, hidden or not, then the cp should copy those four files into it. Then ls -l /home/user/.gpe should show them plus whatever else is in there, regardless of whether it's "hidden".

By the way, the initial dot in a file or directory name doesn't really "hide" the entry, it's just that ls and echo * and similar commands don't show them, while these do:

ls -la
ls -d .*
ls -d {.*,*}
echo .*
echo {.*,*}
Dennis Williamson
Originally, I couldn't see any error messages from executing my script. I can incorporate your suggestions and give them a try. I'll let you know how well it works out once I made the changes.
stanigator
+1  A: 

If that's the entirety of your script, it's missing two. possible three, things:

  • A shebang line, such as #!/bin/sh at the start
  • Use of $SVNPATH. You probably want to cd $SVNPATH before the cp command. Your script should not assume the current working directory is correct.
  • Possibly execute permission on the script: chmod a+x script
camh
+1  A: 

Do you already have the /home/user/.gpe directory present? And also, try adding a -R parameter so that the directories are copied recursively.

bad zeppelin