Any Way To Store Output Of A Script

Hello,

Is there any way to run a script and have dopus store its output into a variable? As a hypothetical example, lets say I have a script that when run in the command prompt it would output a random letter, such as 'm'.

So, I want to create a button that does something like:

C:\home\script.exe
<some method to store the output from this script ie 'm'>
Copy "C:\hello.exe" TO "C:\temp<OUTPUT FROM ABOVE>.exe"

-> so in this example, dopus would copy c:\hello.exe to c:\temp\m.exe, having retrieved the letter 'm' by running script.exe

You could probably create a custom environmental variable and set the value of that with a script. However for such situations I prefer to write the output of a script to a temporary file which can be read later by other scripts or programs. For example the following command line script sets the value of variable X to m and then writes it to a temp file in the C:\ root directory.

@echo off set X=m echo %X%>C:\tempfile.txt

Thanks for the reply - but I'm not sure how this would integrate into a dopus function -

this is what I'm trying to do:
everytime i click the dopus button it should run the script and then use the output from that script to do something else, such as assign it as the new file name.

so, in the example i originally posted, every time i hit that button, it will copy hello.exe to a random file name - maybe s.exe the first time, maybe b.exe the next time, maybe r.exe the next time (based on whatever letter script.exe happens to generate)

Basically, I just want my button in dopus to first run a script and store the text from the output of the script into some kind of string variable

then on the next line i can integrate whatever is contained in this variable into some other opus command, which in my example was to use it as the destination file name in a copy command

What kind of a script are you referring to? A command line (Batch File) script? If so you could set up an Opus button that would send the selected file(s) to the script and then do everything else from within the script. Including using Opus to copy the files giving them a new name.

How does your script give its output? In a DOS box so to speak?

Thanks for the reply.

Well, it would be a perl script, which yes, it outputs the text in a dos box.

So, what you're saying is I can pass the filename to the perl script and use perl to copy the file...? That would work, but I would have preferred to do the actual file copy within dopus.

Wait - I missed a point you made. How can I use dopus to do the actual file copy if I am running things from perl? Running some kind of dopus command line function?

I'm pretty weak in Perl but with standard command line scripts (Batch files if you will), you can run Opus commands from a command line by prefixing the command with

dopusrt /cmd

If necessary, you may need to include the full path to where dopusrt.exe is stored on your machine, in my XP box it's

C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe

For example, if you have an Opus button set up like this:

"D:\Mine\cmd\Test.cmd" {f}

It will send the fully qualified name of the file or folder you have selected in Opus to a script named Test.cmd. In that script you could process that file name as you want, then use an Opus command to finish it up. Here's a rudimentary example: Suppose the output of your script is stored in a variable named X, the following command line script would use an Opus command to copy the original file to a different location while giving it the new name defined by variable X.

[code]@echo off

:: Simulate an output result of a Perl script
set X=m

dopusrt /CMD Copy "%~1" To "C:" As "%X%%~x1"

:: Next two lines are only in for debugging purposes
pause
exit[/code]

Now whether you can adapt this to use with Perl, I have no idea. But if you can, once you have your script all set up and debugged, you can even hide the "DOS box" that pops up so it appears Opus is doing everything.

Thanks a lot for taking the time to give such a detailed reply! I didn't think about using dopusrt /cmd (i've never used it before). I think this will work just fine from perl and do what I wanted.

I don't know if perl will hide the dos box or not... is there another way to do that?

You do that in the Opus button command that you'll use to start the whole process. Just put

runmode hide

As the first line in the Opus button code. However I wouldn't do that until you've made sure you have everything working as it should.