Can't rcmd with star name

We have had a script here for years used to send files to other computers or to rcmd a command entered thru a prompt. A file we are looking for on the other computers will start with the same characters followed by -nnnnnn.txt. I can log into another computer and find (or not) that file, but not with a rcmd. This is the relevant part of the script:

    read cmdname
    date >>/usr/tmp/fixit.x$tstamp
    echo "Running $cmdname" >>/usr/tmp/fixit.x$tstamp
    exec 9</usr/shells/remote.list
    while in=`line <&9`
    do
       echo $in
       echo $in >>/usr/tmp/fixit.x$tstamp
       set  $in
       in=$4
       rcmd $in $cmdname 2>&1 |tee -a /usr/tmp/fixit.x$tstamp
    done

A command like "ls -l /dir1/dir2/FILEONE-.*" doesn't work.

Any ideas? TIA This is a SCO machine but the remotes may be SCO or Linux.

Saying a command doesn't work without telling us what happens and in what way it doesn't work leaves us with lots of things that we could imagine and nothing that we can base any realistic suggestions that might be able to solve your problem.

One might guess that the asterisk is being expanded to a list of files on your local machine by the shell that is collecting arguments before invoking rcmd in the loop. Are there files on your local machine that match the filename component when $cmdname is expanded? Are the files matched on the local machine the same files that would match if that pattern were expanded on each of the remote machines?

1 Like

This morning I tried it again with "ls -l /dir1/dir2/FILEONE*" and that shows up at the top of the log. If I sent it to bb123456, what comes back is

ls: /dir/dir2/FILEONE-998877.txt not found: No such file or directory (error 2)

That file does not exist on this computer--the remote computers compress it with other files to send it to us. That file does exist on bb998877, though.

I have tried enclosing the entire command in single quotes and double quotes in separate tests. What I get is

sh: ls /dir1/dir2/FILEONE*:not found

and at linux branches the "sh" is replaced by "bash".

Thanks for looking at it.

Hold it. We all are just poking in the dark.

Please draw the entire picture, including sensible error messages. An execution log of the program run (set -x option) might be helpful.
Pls show

  • the meaning of "shows up at the top of the log"
  • the contents of /usr/shells/remote.list
  • the result / contents of in=$4
  • the meaning of -nnnnnn.txt
  • the meaning of bb123456 and bb998877
  • the files existing in the target directory on the targets node(s)

You may want to try to enclose the $cmdname in double quotes in the rcmd command.

3 Likes

Just enclosed $cmdname in double quotes and it worked!

Many thanks!