Home
TeamSite
Deleting Files progromatically
Hazzie
I am trying to create a bit of code that will delete a file from my workarea using perl however the unlink command does not seem to be working correctly.
The user selects a file and then from a custom menu chooses an option called 'Delete Asset'. This then kicks of a bit of code which searches through all the xml to see if this file is mentioned in other files. If its menitoned then there is a link to it on another page of the web site and we do not allow the user to delete it. If this file cannot be found it then asks the user to confirm that they wish to delete it. The user clicks on a hyper link which calls a second custom cgi script and is passed the path to the file and the file name. This then using the unlink command attepts to delete it but fails.
here is some code from the second cgi
$Asset = $cgi->{'form'}{'Asset'};
$Folder = $cgi->{'form'}{'Folder'};
print "$Folder$Asset \n";
$ret = unlink '$Folder$Asset';
print "ret $ret";
---
ret always returns 0
Can i at the point of the user selecting yes to confirm the delete programaticaly kick off the TeamSites internal delete command?
Cheers,
Hazzie
Find more posts tagged with
Comments
mogoo
Hazzie-
Did you ever get this working? Have you gotten the unlink function to work? I'm looking for something similar, but even simpler...
A replicant within a DCR has an image associated with it. If the replicant is expired, the image should be auto-deleted from the workarea, then the deletion iwsubmitted to staging.
Has anyone done anything like this? What does the File->Delete menu item call on? Seems like there should be an "iwrmfile" CLT, but there isn't....
Thoughts? Suggestions?
thanks!
maureen
nipper
Hey Maureen
I do not think there is a iwrmfile clt, I think IW relies on the underlying OS for the delete process & thus /usr/bin/rm is what you would use (on Unix)
However you may run into the problem I see which is formapi runs as iwui with 0 permissions (by default) andI have had trouble getting file manipulation done with formapi
Andy
mogoo
Andy-
Thanks a lot, that's exactly what I was looking for! (I think) You were right, if I put it in a tpl (`/usr/bin/rm $file`) and try to run it from the gui, no go.
But it works if I run it from the command line, so I'm thinking it's going to work if it runs as a nightly cron.
Thanks for the help!
maureen
Adam Stoller
How are you defining your custom menu item in iw.cfg - are you doing it as "foo.cgi" or as "/iw-bin/iw_cgi_wrapper.cgi/foo.cgi" ?
I think you may need the latter and that the problem you are having with unlink() and rm is that the user actually attempting to perform the operation (the process owner) is not the logged in user and may not have access to the workarea to do the job.
--fish
(Interwoven Senior Technical Consultant)
Hazzie
We managed to get it working in the end.
If you want details pm me your email address and I will tell you about our 'problem' and how we got round it.
Hazzie
TS 5.5.2 on NT.
Migrateduser
Hi Hazzie
Can you please send me the solution, i mean code etc at this mail id:
pc_nainwal@rediffmail.com