User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Perl section within the Software Development category of DaniWeb, a massive community of 423,490 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,685 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Perl advertiser: Programming Forums
Views: 1010 | Replies: 4
Reply
Join Date: Jun 2008
Posts: 11
Reputation: Scruffstone is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Scruffstone Scruffstone is offline Offline
Newbie Poster

Calling perl from java and file permissions

  #1  
Jun 12th, 2008
Hi there,

I'm trying to open up a text file read info from it, alter it and write back the alterations when a user clicks on the save button, but I've hit two issues:-

1) I can't open the file for write access as I don't have permissions - can I alter a files permissions during a program using chmod? I've tried to alter it by hand in an ftp window (to 755 from 666) but it just stays the same.

2) A button (in perl) calls a java function only as far as I can find out, can I use it to call a perl function instead? if so could I have an example like this:-

 print "<button type=button onClick=\"update_file()\">Save1</button>";

update_file() being the perl sub that I'd like to call.

If I can't do this and have to call a java function can I then call the perl sub from there instead, I've tried it like this but it doesn't do anything so I'm presuming it doesn't work:-

print "function update_file ()\n";
print "{";
print "update_input_filehandle_with_local_text ()";
print "}\n";

many thanks in advance for your help
Sarah
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2006
Posts: 618
Reputation: KevinADC is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 33
KevinADC's Avatar
KevinADC KevinADC is offline Offline
Practically a Master Poster

Re: Calling perl from java and file permissions

  #2  
Jun 12th, 2008
javascript and perl are two entirely different things. Perl has no concept of javascript and the same is true in reverse. What you need to do is a send some data to your perl script via a CGI form and use that data to tell your perl script what to do, like run a certain subroutine in your perl script.

As far as the chmod goes, it is possible to change file permission with perl, use perls chmod function.

http://perldoc.perl.org/functions/chmod.html
Last edited by KevinADC : Jun 12th, 2008 at 8:58 pm.
Reply With Quote  
Join Date: Jun 2008
Posts: 11
Reputation: Scruffstone is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Scruffstone Scruffstone is offline Offline
Newbie Poster

Re: Calling perl from java and file permissions

  #3  
Jun 13th, 2008
ah ok so java and perl can relate to the CGI form. So I could say have the button call a java function that sets a variable to true that is being checked by a while loop and when found to be true call the perl sub? is that the sort of thing you mean?

many thanks
Sarah
Reply With Quote  
Join Date: Mar 2006
Posts: 618
Reputation: KevinADC is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 33
KevinADC's Avatar
KevinADC KevinADC is offline Offline
Practically a Master Poster

Re: Calling perl from java and file permissions

  #4  
Jun 13th, 2008
javascript can only communicate with the perl script via the form. Do whatever you want with the javascript, but it has to set a form field to some value and then send the form data back to the perl script to process the data. Perl then accepts the data, processes it, and sends data back to the browser. But there is never any direct interaction between perl and javascript, they operate in two different environments, they can only communicate via the form.

Perl can print javascript while it outputs html back to the web browser and fill in javascript code with whatever data is needed by the javascript to run in the web browser, but once perl outputs the html/javascript code to the web browser it has no concept of what occurs after that until some form data is sent back to the perl script via the form.

There is also AJAX which is a blending of javascript and CGI scripting, but the process is essentially the same as described above although the interaction in the web browser looks different.
Reply With Quote  
Join Date: Jun 2008
Posts: 11
Reputation: Scruffstone is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Scruffstone Scruffstone is offline Offline
Newbie Poster

Re: Calling perl from java and file permissions

  #5  
Jun 14th, 2008
That's a great help thanks very much - I've nearly sorted it now

Sarah
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Perl Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the Perl Forum

All times are GMT -4. The time now is 3:59 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC