473,796 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Puzzling form/cgi problem

Hi.

I have a problem with a subroutine in a cgi script that's supposed to
return the byte location at the end of a file, which the script then
stores as a hidden input on a web form.

Unfortunately, even though it works fine in the python shell, in the
cgi-script it always returns "0". That's no use to me at all.

Here's the subroutine..... .

def getLastByteLoc( log):
#open log file
f = open(log)

#seek to end of log file.
f.seek(0,2)

location = f.tell()
f.close()
return location

Jul 18 '05 #1
2 1590
Dfenestr8 wrote:

I have a problem with a subroutine in a cgi script that's supposed to
return the byte location at the end of a file, which the script then
stores as a hidden input on a web form.

Unfortunately, even though it works fine in the python shell, in the
cgi-script it always returns "0". That's no use to me at all.


Not sure about a fix for the seek() problem, by can't you just use
os.stat() to get the size of the file?

-Peter
Jul 18 '05 #2
On Mon, 03 Nov 2003 06:23:24 +1000, "Dfenestr8" <ch************ **@yahoo.com.au > wrote:
Hi.

I have a problem with a subroutine in a cgi script that's supposed to
return the byte location at the end of a file, which the script then
stores as a hidden input on a web form.

Unfortunatel y, even though it works fine in the python shell, in the
cgi-script it always returns "0". That's no use to me at all.
If you want to use that routine, you might want to return something distinctive in case
of exceptions. E.g., perhaps the cgi prog can't see the file the way you are specifying it
(is it a full path? Is that legal in the context of the cgi, which are sometimes constrained
to access down a particular subtree?) or doesn't have adequate permissions (cgi is probably
running as "nobody" or some other server user id, and running in a different default directory).
Here's the subroutine..... .

def getLastByteLoc( log):
#open log file
f = open(log)

#seek to end of log file.
f.seek(0,2)

location = f.tell()
f.close()
return location


Regards,
Bengt Richter
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
1987
by: George Sakkis | last post by:
I'm looking for a design to a problem I came across, which goes like this (no, it's not homework): 1. There is a (single inheritance) hierarchy of domain classes, say A<-B<-..<-Z (arrows point to the parent in the inheritance tree). 2. This hierarchy evolved over time to different versions for each class. So for example, version's 1 hierarchy would be A_v1 <-B_v1 <-..<-Z_v1. 3. At runtime, only one version is selected by a factory...
6
1640
by: oeyvind toft | last post by:
I have a frameset consisting of 3 frames: top, left and right. In top frame: body onload calls a js init function to set (or resets) values in textareas etc...in all frames. In right frame: A large textarea for dynamicly updated text. Problem: When clicking the browser 'update' this doesnt work: myTextAreaOnTheRight = ""; UNLESS I put an alert(anything) before the statement.
1
2131
by: John Wharmby | last post by:
Hi there, I have been stumped by a where statement! (Thought it would never happen!) I have a database that stores parts of postcodes for a survey to see where our customers have traveled from, and I want to query it to produce count totals in a report. I have already built the report and it works good querying the data as I want it, producing totals per code. However, i don't want the whole lot all the time. When I use a WHERE in...
2
1158
by: Randy Harris | last post by:
I have a form with an unbound text box. The text box has a default value of Date(). All of a sudden, a couple of the systems have #Name? appear in the text box when the form is opened (instead of the Date). Anyone have an idea of what might be causing this?
18
2484
by: Michael Press | last post by:
Hello. I am puzzled. A line of the form char array = { a}; or char array = { a, b, c}; is an array initializer.
2
1778
by: Aeryn | last post by:
I have a windows solutions containing three forms. All works fine until I customize a form's Icon property. The icon displays fine in the IDE but if I try to run the application it throws "System.Resources.MissingManifestResourceException" before the main from is displayed. I've looked in the corresponding resx file and there is an entry for the icon. Why am I getting this problem and more importantly how do I fix it thanks,
36
2097
by: Robert Baer | last post by:
I used Google and found some references for integer in Java. But "int" not only does not work, it also prevents reading X and Y coordinates of the mouse. What i would like to do: 1) Get X and Y mouse coordinates into a variable that i can do real math on. So far, i can do math on the values "read" and that result goes into a "variable" that is useful *only* for display. If i try "int" in that math, the values are then zero for everything...
1
2123
by: Chris Dunaway | last post by:
When working with GDI+, calling the CreateGraphics method to draw on a control has normally been frowned upon and it is always emphasized to dispose of pens and brushes and other GDI objects lest you run out. But consider the following code (in a timer elapsed event on a Windows Form): private void TimerFunc(object sender, System.Timers.ElapsedEventArgs e) { Graphics gdi = this.CreateGraphics();
1
2814
by: eBob.com | last post by:
I have some code which is trying to determine where text will wrap in a custom text box (which Inherits from Control). It determines the number of characters which will fit in the first line, but then encounters an exception when it calls MeasureCharacterRanges to see if the next character, i.e. the one destined to become the first character of the second line, will fit. The message says only "Invalid parameter" - it does not say which...
0
9525
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10452
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10221
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5569
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.