recognizing * character

i have a short script that takes a filename and secure copies the file to a remote machine. i'd like to be able to take a * character and secure copy all the files in the directory.

first of all, how would i compare $1 to see if it's a * character?

if [ $1 = '' ] or [ $1 = '\' ] didn't do it.

second question is how would i tell the shell script to do 'scp * user@<ip>:/'? or do i have to do it one by one in a loop?

When you run your script you gotta do:
./yourscript \*
if you just do
./yourscript *
the shell will replace * with a list of filenames before your script even runs.

It sounds to me like you're trying to do the work that the shell already does for you.

Say I cd to /tmp and do ls * . Say it comes back with
file1 file2 file3

Then I create a script in my home directory. Call it foo. Now I cd to /tmp, run the command foo, with * as an argument: ~/foo * . Note that the script "foo" is NOT given a * as an argument. Because what the shell does, before it even executes the command (which is my shell script), is to: Expand variables, Expand metacharacters, and Expand commands in backticks (or $( ...) in ksh ). So when I type

~/foo  *

, the shell does not run

~/foo  *

. It expands the *, and really runs

~/foo   file1 file2 file3 

.

So what you're thinking of doing is actually

 scp  $@ user@ip:

I don't believe you need or want a directory in the "user@ip:" part of the scp because your files will by default be placed in the home directory of user over at your host given by ip.

Finally, I'm not sure of the syntax of the scp command with multiple files. Try doing two of them first, and see if it works. Remember that metacharacters aren't magic, they are pretty ignorant although powerful. What they do is serve as placeholders for a replacement. The shell does the replacing, then and only then does your script or command get the results of the replacement(s).
-mschwage

thanks for the explanation. you guys are awesome.