replace filename with string in way that can fool apps that require a filename

replace filename with string in way that can fool apps that require a filename

Post by Jado » Mon, 25 Feb 2002 09:29:29



I have a script (PHP running as CGI in this case)

I use it to call gpg with a text string that I have.
My command inside the PHP scripts that gets executed at the shell
level is:
-------
<?php
$message = "some text comming in from space";

$fd = fopen('some/path', "w");        // make a file

fwrite($fd, $message);  // write my variable string to it

fclose($fd);    // close the file

// here I build the command to execute. So I pipe the temp file to gpg
$command = "cat " . $path . " | /usr/bin/gpg...snip... -e -
".$message;

exec($command, $encrypted);     // execute..
//(encrypted contains the result of command)

unlink($path);  // and eventually delete the file
?>
---------------
Don't worry about the php. The main point here is the line that starts
with $command. Notice that I am creating a file just to send it to
GPG. Is there a way to directly send the $message variable in a manner
that gpg will be happy. Maybe there is a way to create a 'virtual
file' or pehaps I thought that I could echo $message and somehow give
gpg the device name of the output device but I;m not sure how to do
anything like that.

Thanks

Joshua

 
 
 

1. file of filenames, trying to execute %> cat filename

this is not my ultimate goal, but I thought I should test this before
writing the full script.

I have a file of filenames.
file1:
dog
cat
fish

not I want to execute the following script;
I can't figure out why I cannot get the script to run without the error
message

the script:
1  #!/bin/sh
2
3  prefix="~/tempdir"
4
5  for filename in `cat dfiles`
6  do
7      TARGETFILE="$prefix/`echo $filename | sed 's/.*\/\([^\/]*$\)/\1/'`"
8      echo $TARGETFILE
9      cat $TARGETFILE
10 done

only line 10 seems to be the problem

the error message:
[schoi_d11776b] % compfiles
~/tempdir/dog
cat: cannot open ~/tempdir/dog
~/tempdir/cat
cat: cannot open ~/tempdir/fish
~/tempdir/cat
cat: cannot open ~/tempdir/fish
[schoi_d11776b] %

the strange thing is that I am able to perform
%> cat ~/tempdir/dog
on the command line just fine; it just doesn't like executing the
command in the script

ls -l for the file and directory says
drwxrwxrwx - for directory
-rwxrwxrwx - for the files

would appreciate your insights as to what i'm doing wrong

thanks
Sean

2. A better way?

3. How to change Windows-compliant filenames to Unix filenames

4. RPM/DPKG for Commercial Use?

5. Change Upper case filename to lower case filename

6. Just upgraded to ELF - now can't compile kernel - help!

7. Capturing an a filename that contains the month/date in filename ie fileMMDD

8. Win-Clients on Hylafax: Bad Password...

9. a file of filenames compared to another file of filenames

10. renaming files from filename to filename-date

11. Find and replace filenames

12. replace 8-bit-characters in filenames

13. search - replace - perl -i -p -e "s/$var/sda/" /etc/filename