Posted: Mon Jan 16, 2006 2:58 pm
I found another bug in the CC_RELINK_LOST_IMAGES.createSubDirList function: should actually be something like:
The tilde (~) thing doesn't work in Lua.
Next, I got this error message:
So that boils down to the following code not being executed properly:
The Programming in Lua book warns for using os.execute in crossplatform situations:
I get the following contents of the "~/mohoimpd" file: (a change directory command to the folder in which the Moho file is located, and a list structure command)
If I execute this file in my BASH CLI, this dialogue appears:
So I did the following:
Now the "mohodlst.dat" file appeared in the same folder as the Moho file, but contained only a period character ".".
And indeed, if you execute at the CLI, you only get the period character. I assume you want a complete list of subdirectories over all mounted drives, but this -d1 option obviously isn't the one to use.
I changed the script by inserting the chmod command:
But then, of course, I got another error message:
Judging from the name of the function (createSubDirList) I guess the "ls -d1" command should have created a list of all subdirectories over all mounted drives.
Please give me some feedback on this, because I'm really in the dark here. I'm not exactly sure what I'm doing or are supposed to do next.
Code: Select all
batchScript = "~/mohoimpd"
Code: Select all
local homeDir = os.getenv("HOME")
batchScript = homeDir .. "/mohoimpd"
Next, I got this error message:
This probably means the batch file "~/mohoimpd" wasn't executed and therefore the file "mohodlst.dat" wasn't created by the batch script.CC:Relink Lost Images wrote:
So that boils down to the following code not being executed properly:
Code: Select all
local result = os.execute ( batchScript ) --no chmod??
Anyway, if I comment out theProgramming in Lua wrote:The function os.execute runs a system command; it is equivalent to the system function in C. It receives a string with the command and returns an error code. For instance, both in Unix and in DOS-Windows, you can write the following function to create new directories:The os.execute function is powerful, but it is also highly system dependent.Code: Select all
function createDir (dirname) os.execute("mkdir " .. dirname) end
Code: Select all
os.remove (batchScript)
Code: Select all
cd "/Users/renevanbelzen/Desktop/relink images/"
ls -d1>mohodlst.dat
If I execute this file in my BASH CLI, this dialogue appears:
Code: Select all
CP756652-A:~ renevanbelzen$ ./mohoimpd
-bash: ./mohoimpd: Permission denied
Code: Select all
CP756652-A:~ renevanbelzen$ chmod +x mohoimpd
CP756652-A:~ renevanbelzen$ ./mohoimpd
And indeed, if you execute
Code: Select all
ls -d1
I changed the script by inserting the chmod command:
Code: Select all
if(platform == "unix") then
local permission = os.execute ( "chmod +x " .. batchScript ) -- chmod
end
local result = os.execute ( batchScript ) -- execute
The code at the end of the CC_RELINK_LOST_IMAGES.createSubDirList function produced this error, probably because the unix command "ls -d1" doesn't do what it is expected to do.CC:Relink Lost Images wrote:
Judging from the name of the function (createSubDirList) I guess the "ls -d1" command should have created a list of all subdirectories over all mounted drives.
Please give me some feedback on this, because I'm really in the dark here. I'm not exactly sure what I'm doing or are supposed to do next.