Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
JoeNotCharles
Mar 3, 2005

Yet beyond each tree there are only more trees.
You know, I'm not sure exactly why I get the results I do, but:

code:
$ ./foobar -pants
this is a test
file1
file2
$ for i in `./foobar -pants`; do echo $i; done
this
is
a
test
file1
file2
$ for i in `./foobar -pants`; do echo "$i"; done
this
is
a
test
file1
file2
Yeah, you knew that. Here's something that works:

code:
$ for i in "`./foobar -pants`"; do echo "$i"; done
this is a test
file1
file2
Here's something that doesn't, and I'm not sure why not:

code:
$ for i in "`./foobar -pants`"; do echo $i; done
this is a test file1 file2

Adbot
ADBOT LOVES YOU

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

JoeNotCharles posted:

code:
$ ./foobar -pants
this is a test
file1
file2
$ for i in `./foobar -pants`; do echo $i; done
this
is
a
test
file1
file2
$ for i in `./foobar -pants`; do echo "$i"; done
this
is
a
test
file1
file2

This is splitting on all whitespace, and calling echo for every word.

JoeNotCharles posted:

code:
$ for i in "`./foobar -pants`"; do echo "$i"; done
this is a test
file1
file2

This isn't splitting at all, and calling echo exactly once, with the entire output of foobar.

JoeNotCharles posted:

code:
$ for i in "`./foobar -pants`"; do echo $i; done
this is a test file1 file2

This isn't splitting at all, and calling echo exactly once, with the entire output of foobar. Because the variable isn't quoted, it is split into multiple words on whitespace, which are then all passed to echo as separate arguments. Echo doesn't know how its arguments were split, so it assumes a single space.

This should work:
code:
OLDIFS="$IFS"
IFS="
"
for i in `./foobar -pants`; do echo $i; done
IFS="$OLDIFS"

Lexical Unit
Sep 16, 2003

JoeNotCharles:
Yup, I was hung up trying the same things and still not getting the behavior I wanted (as ShoulderDaemon pointed out: you're results are deceiving, none of them work).

ShoulderDaemon:
I was hoping there was a simpler solution but I was kinda expecting that the solution would involve changing the delimiter somehow. Didn't know how to do that tho, but now I do :)

covener
Jan 10, 2004

You know, for kids!

Lexical Unit posted:

JoeNotCharles:
Yup, I was hung up trying the same things and still not getting the behavior I wanted (as ShoulderDaemon pointed out: you're results are deceiving, none of them work).

ShoulderDaemon:
I was hoping there was a simpler solution but I was kinda expecting that the solution would involve changing the delimiter somehow. Didn't know how to do that tho, but now I do :)

Using the shell builtin 'read' may be a more straightforward way to iterate over line-based output

code:
./foo.sh | while read F; do echo $F; done
this is a test
file1
file2

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

covener posted:

Using the shell builtin 'read' may be a more straightforward way to iterate over line-based output

The only gotcha with that is it opens a subshell, so you can't set environment variables within the loop and have them propagate outside it unless you jump through some extra hoops. Depending on what kind of processing he's doing inside the loop, that may or may not matter.

Lexical Unit
Sep 16, 2003

covener posted:

Using the shell builtin 'read' may be a more straightforward way to iterate over line-based output
Neat! Gotta keep the subshell issue in mind, but at least with read the solution is easier on the eyes.

Deus Rex
Mar 5, 2005

A Scheme question here... (note that this is using DrScheme, which I think replaces some of the more weird definitions like 'car' and 'cdr' with the more clear 'first' and 'rest'. If something isn't clear, let me know)

I was assigned to write a Scheme function (calc-running-sums L) which evaluates to a list that is the running-sums of the list L. For example, (calc-running-sums '(1 2 3)) gives '(1 3 6).

My solution is, in my view, not very elegant. It's something that came to me early on when I approached the problem, but which I put on the backburner because of its inelegance. I spent a good amount of time trying to find a more elegant solution, but I haven't been able to. My solution uses several helper functions which I've also included.

code:
;; (list-length L)
;;
;; returns the length of the list L.

(define list-length
  (lambda (L)
    (cond
       ((empty? L) 0)
       ((not (empty? L)) (+ 1 (list-length (rest L)))))))

;; (sum-of-first n L)
;;
;; returns the sum of the first n elements of L
(define sum-of-first
  (lambda (n L)
    (cond
      ((empty? L) 0)
      ((= n 1) (first L))
      (else (+ (first L) (sum-of-first (- n 1) (rest L)))))))

;; can't think of a better name for this
;; this is the "real" work done in (calc-running-sums)
;; returns a reversed running sums list

(define calc-running-sums-helper
  (lambda (n L)
    (cond
      ((= 0 n) empty)
      (else
       (cons (sum-of-first n L) (calc-running-sums-helper (- n 1) L))))))

;; (calc-running-sums L)
;;
;; Start off with list like (1 2 3 4 5)
;; End up with list like: (1 3 6 10 15)

(define calc-running-sums
  (lambda (L)
    (reverse
     (calc-running-sums-helper (list-length L) L))))
Since my professor won't dock points for style on this assignment (we only covered Scheme for about two and a half lectures), this is probably what i will end up turning in. I'm wondering though if anyone else has some hints that might help me figure out the elegant solution to this problem, which I'm sure exists.

Meganiuma
Aug 26, 2003
Oops, double post.

Meganiuma fucked around with this message at 14:54 on Jun 6, 2008

Meganiuma
Aug 26, 2003
My scheme is very rusty, but here's a shorter solution. There might be a way to do this without all the reversing i've done, but I can't think how off the top of my head.(This is essentially the same as your solution, but just using the built-in fold-right)

code:
(define (calc-running-sum L)
  (reverse (sum-l (reverse L))))

(define (sum-l L)
  (if (empty? L)
      empty
      (cons (foldr + 0 L) (sum-l (rest L)))))

Meganiuma fucked around with this message at 15:04 on Jun 6, 2008

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender
You can do it without a reverse and with a single pass through the list by carrying an accumulator with the previous element's sum.

code:
(define (calc-running-sum L) (calc-running-sum-acc 0 L))

(define (calc-running-sum-acc n L)
  (if (null? L)
    '()
    (cons (+ n (car L)) (calc-running-sum-acc (+ n (car L)) (cdr L)))
  )
)

Deus Rex
Mar 5, 2005

ShoulderDaemon posted:

You can do it without a reverse and with a single pass through the list by carrying an accumulator with the previous element's sum.

code:
(define (calc-running-sum L) (calc-running-sum-acc 0 L))

(define (calc-running-sum-acc n L)
  (if (null? L)
    '()
    (cons (+ n (car L)) (calc-running-sum-acc (+ n (car L)) (cdr L)))
  )
)

:o: of course! this was actually my original plan for this but I guess it got retarded down into my crappy solution. Thanks.

Meganiuma posted:

another good solution
We were only allowed to use a very limited subset of the built-in Scheme functions (that didn't include fold-right), but thank you :)

myownsavior
Dec 21, 2004

I operate a nuclear reactor.
Is trying to learn Objective C (for use w/ XCode and Cocoa) a terrible idea if I don't know anything about the C language?

I've heard people recommend it, and others say you're doing yourself a big disservice by not learning C first.

I'm trying to learn an OOP language this summer, and the only programming experience I have lies in a bit of Pascal, Perl, and PHP.

JoeNotCharles
Mar 3, 2005

Yet beyond each tree there are only more trees.

myownsavior posted:

Is trying to learn Objective C (for use w/ XCode and Cocoa) a terrible idea if I don't know anything about the C language?

I've heard people recommend it, and others say you're doing yourself a big disservice by not learning C first.

I'm trying to learn an OOP language this summer, and the only programming experience I have lies in a bit of Pascal, Perl, and PHP.

I'd say you'll probably find it easier without knowing C, because you won't be bouncing off the Smalltalk-isms saying, "But, but, that's nothing like C!"

Cody Watts
Jun 5, 2004
The internet makes you stupid.
This isn't a programming question per se - more of a windows question - but I think it's appropriate:

Say I have an application (a computer game), and I want to associate my save files (.sav) with the application, so that I can just double-click on them and the game will start up and load that save automatically. Now, say also that my game has a whole bunch of external files it relies on - textures, sounds, whatever. Suppose that these files are located in subdirectories, relative to the game directory (e.g. C:\MyGame\Textures, C:\MyGame\Sounds, etc.)

My problem is this: When you run the game through file-association (that is, by double-clicking on a .sav file) or by dragging and dropping the .sav file onto the executable, the application uses the location of .sav file, not the .exe as the working directory. This creates problems if you run the .sav from, say, C:\MySaveFile and then the application goes looking for C:\MySaveFile\Textures.

Has anyone worked with this problem before? Can anyone think of a way around it? So far my best guess would be to write the location of the .exe to the registry, and then read and use that value as the working directory when the program starts up. But I'm hoping there's an easier way...

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

Cody Watts posted:

Can anyone think of a way around it?
I'm pretty sure the Windows API has a call to set the current working directory. I don't remember what it's called, though.

JoeNotCharles
Mar 3, 2005

Yet beyond each tree there are only more trees.

Cody Watts posted:

Has anyone worked with this problem before? Can anyone think of a way around it? So far my best guess would be to write the location of the .exe to the registry, and then read and use that value as the working directory when the program starts up. But I'm hoping there's an easier way...

The standard way on Unix is to look at argv[0], which has the full path to the executable. I'm not sure if Windows does the same or just has the filename, but it's work a try. (Of course, on Linux this is usually pretty useless because all the executables are together in /usr/bin.)

I think it's pretty standard to have the installer write the locations of data files to the registry, though. Old CD-ROM games used to do this because they'd install some data files and leave others on the CD - I remember tricking them into doing full installs by copying everything off the CD and then changing the paths in the registry.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

JoeNotCharles posted:

The standard way on Unix is to look at argv[0], which has the full path to the executable.
Not necessarily. I put an argv-printing program in a directory in my path and get whatever string that I call the program as:
code:
% gcc -std=c99 args.c 
% ./a.out 
./a.out
% ./a.out hi
./a.out
hi
% mv a.out bin/
% a.out
a.out
% bin/a.out
bin/a.out
% ./bin/a.out 
./bin/a.out
% ././././bin/a.out 
././././bin/a.out
%
I'm on Fedora 8 & bash.

No Safe Word
Feb 26, 2005

Mustach posted:

Not necessarily. I put an argv-printing program in a directory in my path and get whatever string that I call the program as:

I'm on Fedora 8 & bash.

This is (and always has been) the way it will/should work.

JoeNotCharles
Mar 3, 2005

Yet beyond each tree there are only more trees.

Mustach posted:

Not necessarily. I put an argv-printing program in a directory in my path and get whatever string that I call the program as:

Uh, you're right, I don't know what I was thinking. This is how things like busybox work - you symlink the same executable to a bunch of different names, and then check which function of the program to run by checking argv[0] to see which name was used to invoke it.

It still might work in this case, though, because it's the OS filling in the file path so I'd assume it'd use the absolute path.

covener
Jan 10, 2004

You know, for kids!

Cody Watts posted:

Has anyone worked with this problem before? Can anyone think of a way around it? So far my best guess would be to write the location of the .exe to the registry, and then read and use that value as the working directory when the program starts up. But I'm hoping there's an easier way...

You want to use GetModuleFileNameW() to find the canonical path to your running executable, then work your way backward to some directory of interest.

Cody Watts
Jun 5, 2004
The internet makes you stupid.

Mustach posted:

I'm pretty sure the Windows API has a call to set the current working directory. I don't remember what it's called, though.

JoeNotCharles posted:

It still might work in this case, though, because it's the OS filling in the file path so I'd assume it'd use the absolute path.

covener posted:

You want to use GetModuleFileNameW() to find the canonical path to your running executable, then work your way backward to some directory of interest.

Thanks for your help, guys! Between the three of you, I managed to get it working. :)

tripwire
Nov 19, 2004

        ghost flow
Apologies if this is a huge wall of words, but I figure worst case is no one reads or replies to it, best case I get some help.

I've been trying to change a genetic algorithm which is normally done in serial to run in parallel.

Because I'm using Python and just read a tiny bit about functional programming I decided it would be easier for me to get rid of internal states as much as possible and just use different immutable dealies and functions, as it might be easier to understand where the bugs were, and how to parallelize it.

Unlike regular approaches where you take a "population" and replace it with a new one of the same size (i.e. a generation), this algorithm says you have to take a population and perform operations where you remove one and add a new one at the same time. This it improves the search because the "frontier" gets updated every time something is evaluated, rather than every time the entire population is evaluated.

The algorithm looks like this:
code:
-make an initial population, all untested.
Until we reach the stopping condition:
    -group the population into disjoint sets based on their similarities
    Do the following j times:
*       -evaluate every untested member of the population (stopping if any reach the "goal")
*       -remove the worst member of the population
*       -take one of the best of the population at random and have it reproduce a child with random variations
Theres a bit more to it than that but the rest isn't relevant. What I want to do is take the lines which have *s on the left and run them concurrently no multiple processors. By making that part in the inner loop a single function (it takes a population and returns a population) and running it parallel you can cover more ground in search space, so to speak.
The problem is I don't know how to combine the different populations we get from the different processors, after its done the parallel part.

I want it to kind of fork and merge the improvements without losing anything. Since the third part of the inner loop is random (i.e. not a pure function) each processor should return a different population after the parallel part is done.

So the problem is I have these resulting sets with some elements in common and some disjoint, and I want to merge them into a new unified set of the same size.

This single unified set has somehow got to losslessly incorporates all of the changes to the population experienced by the seperate processors. I can compare a resulting set to the prior unified set to see how many elements are disjoint. If there is an element that is disjoint between either, that means it is either a loser who was removed, or a child who was an improvement.

What do I do if population A and population B both have new improvements but they both removed the same loser? Population C can't have both improvements because its only got the one loser to remove and then theres no more space left.

Has anyone done anything remotely similar in the past?

Scaevolus
Apr 16, 2007

tripwire posted:

I've been trying to change a genetic algorithm which is normally done in serial to run in parallel.
Are you trying to optimize something in Python? Maybe you should look into Pyrex or some similar tool before trying to parallelize it.

Python isn't really designed for fast number crunching.

JoeNotCharles
Mar 3, 2005

Yet beyond each tree there are only more trees.

Scaevolus posted:

Are you trying to optimize something in Python? Maybe you should look into Pyrex or some similar tool before trying to parallelize it.

Python isn't really designed for fast number crunching.

The NumPy people disagree. (No, wait, they agree, but they fixed it by extending the language with native modules.)

Anyway, make sure you're using NumPy for your genetic algorithms and such because it'll fix many performance problems right off the bat and contain infrastructure for fixing the rest.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
Tripwire what you want to do is divide your population into n parts where n is the number of processes you want to run in parallel. Each child process finds the worst and best member of their segment of the population and returns the results. Then the parent thread makes n comparisons from the results and finds the best/worst of the entire population and generates the new offspring. This is probably the easiest way to distribute the work.

I know jack poo poo about python, so your efficiency problems might be solved by the other recommendations.

tripwire
Nov 19, 2004

        ghost flow
Thanks for the responses guys. To clarify, I'm not really asking how to optimize my code in python, it was more of an algorithm question. As it is, the vast majority of cpu time is spent on the evaluation step which isn't done in python. My focus isn't optimizing the algorithm so much as foremost figuring out how to reimagine it in parallel, and secondly making it clear, understandable and useful for exploring search dynamics. When I'm satisfied that those objectives are complete I'll switch in numpy and start considering dropping in either c++ extensions or refactoring in pyrex. Forget I ever mentioned python, what I'm asking is for an appropriate way to merge the n disparate sets into a single unified one.

MEAT TREAT: You make a useful suggestion, but unfortunately I cannot distribute the work in that way; ultimately the function I want to parallelize has to receive the complete population for it work, the search dynamics would not function properly if it only received disjoint subsections.

Imagine I have a function called "tick". It takes a population object, with at least 1 member that is unevaluated. The unevaluated is/are assigned a score, and the lowest score in the population is removed. Finally a new unevaluated dude is appended. The resulting population object is returned.

The part of my algorithm I am trying to make parallel will look like this:
code:
loop:
    save a copy of the population as a reference.
    fork population into hmm lets say 10 different copies.
    on each cpu: run tick() some amount of times, lets say 5.
    *uh oh
    somehow we have a single unified population at this point
So that line that says uh oh is where I'm going to have 10 different sets of guys. If you compare any of the 10 new sets to the old one, as many as 5 guys are gonna be different, or as few as 1 (its possible that a guy who gets added at the end of one tick is removed in the next tick).

The hosed up thing is though, knowing which people got removed is almost as important as knowing who is new; if someone gets removed thats like the algorithm saying "this guy is not going to be a stepping stone to anything useful, so lets not waste our time keeping him around".

So I have to kind of figure out a principled way of choosing who to include in the new population.

_aaron
Jul 24, 2007
The underscore is silent.

tripwire posted:

genetic algorithms stuff
This doesn't really answer your question, but I'm curious. From your explanation, it seems like what you want to do is evaluate the same population on multiple processors, and each evaluation has the potential to select a different "loser." If that's the case, why not just evaluate it once and choose however many random losers you want? I may be missing something fundamental here, so go easy on me if I sound like a retard.

tripwire
Nov 19, 2004

        ghost flow

_aaron posted:

This doesn't really answer your question, but I'm curious. From your explanation, it seems like what you want to do is evaluate the same population on multiple processors, and each evaluation has the potential to select a different "loser." If that's the case, why not just evaluate it once and choose however many random losers you want? I may be missing something fundamental here, so go easy on me if I sound like a retard.
No you hit it dead on, there is a potential for different losers to be selected; even though remove_guy() is a pure function (given the same population, it will always remove the same loser), unfortunately the add_guy() function works probabilistically.. that means that when you do a bunch of ticks consecutively, you can end up removing different people by ending up with new guys who are improvements on the losers.

Since removing a guy effectively biases the search from going in that direction, enforcing parallel ticks FORCES search to go in many directions at once (this is a really really good thing). In order to benefit the most from that enforced diversity though, I have to figure out how to take the diverse results of the consecutive concurrent ticks and merge them nondestructively.

Theres some properties about the resulting populations that might make this easier; for example..

Lets say I have reference_pop, and I do a bunch of ticks on 3 different cpus, ending up with result1, result2, result3.

If result1 has 4 new guys, that means compared to reference_pop its also MISSING 4 guys; however it might be missing a different set of people than result2 is; or they both could have removed exactly the same guys; or they both could have removed SOME of the same guys, but other different ones.



My unified population at the end somehow has to have the same number of people, so I even if I remove everyone who was removed in any of the results I still won't have enough room for all the new guys who replaced them (between the different resulting populations, some of the removed dudes overlap, but none of the new guys should overlap).

tripwire fucked around with this message at 23:15 on Jun 11, 2008

checkeredshawn
Jul 16, 2007

Can anyone tell me how to use Sed to remove all text in a file that is not an IP address?

For example:

Name: somesite.com
Address: 39.100.204.200
Name: somesite.com
Address: 202.110.30.50

should turn into:

39.100.204.200
202.110.30.50

tripwire
Nov 19, 2004

        ghost flow

checkeredshawn posted:

Can anyone tell me how to use Sed to remove all text in a file that is not an IP address?

For example:

Name: somesite.com
Address: 39.100.204.200
Name: somesite.com
Address: 202.110.30.50

should turn into:

39.100.204.200
202.110.30.50

probably cleaner ways to do it but sed 's/[a-Z]*[:] //' | sed /[a-Z]/d

To clarify: 's/[a-Z]*[:] //' will substitute every occurence any number of alphabetic characters (including where there is none) followed by a colon and a space with nothing.
The second sed command hides lines with any remaining alphabetic characters.

tripwire fucked around with this message at 20:32 on Jun 11, 2008

Neslepaks
Sep 3, 2003

If the file is always in that format it sounds more like a job for awk than sed, for example:

awk '/^Address/ { print $2 }' file

Montalvo
Sep 3, 2007



Fun Shoe
So this a Fortran 95 question. I've got a data file with about 4 columns of 50000 entries consisting of numbers each. I want my code to scan through lines 30000 - 35000 of column 4 and find the highest entry there. How exactly would I go about doing this?

Sorry if this is a basic question, but I'm pretty new to this coding business. :shobon:

nolen
Apr 4, 2004

butts.
I asked this in the Flash Questions thread but it's not really Flash-specific.

Does anyone have experience writing an FTP client? I'm trying to create a proof-of-concept in actionscript that uses binary sockets to connect to the server.


I can get it connected and logged in, but I'm having problems with commands like LIST and PUT. Research tells me it has something to do with being in PASSIVE mode, or that FTP uses one connection for control and another for data.

Can anyone shed some light on this for me, please?

6174
Dec 4, 2004

Montalvo posted:

So this a Fortran 95 question. I've got a data file with about 4 columns of 50000 entries consisting of numbers each. I want my code to scan through lines 30000 - 35000 of column 4 and find the highest entry there. How exactly would I go about doing this?

Sorry if this is a basic question, but I'm pretty new to this coding business. :shobon:

When you open the file you need to specify the record length. It has been a while since I've done it, so double check my syntax with a reference, but basically

open(LUN, file='filename', recl=rl, access=direct)

Then to read

read(LUN, rec=##) number1 number2 number3 number4

Where the rl is the line length in bytes (which must be the same for everyline otherwise this won't work). And ## is the record number you want to read (ie line number). And LUN is the LUN you want to use for your file (don't forget to close it at the end).

Then to find a max, simply read each record 30k - 35k and do a simple check to see if the just read value exceeds your current max (held in a different variable).

If is is too hand-wavy, let me know and I can code something up this weekend.

edit: If the line lengths aren't consistent you'll have to resort to a stupid styled loop that reads every line, and skips to the next line when you are below 30k and bails out of the loop at 35k.

Montalvo
Sep 3, 2007



Fun Shoe
Yes, unfortunately the lines do not have the same length (actually, on second thought, they might do -- I'll have to check tomorrow, when I get to the computer with the data on it). What you explained is quite new to me, but I recognise some of the commands and will look them up on my Fortran book at some point.

The last time I did something like this was very convoluted: I established a loop that looked at each value of the data and compared it to the previous one -- if the new value was bigger, it added a counter to an array. Whenever there was a discontinuity in the array's counters, it marked the value as a maximum. It worked, but I'm afraid it might take way too long for this program, since it needs to look at several data files with 50000 entries each.

If knowing the context of what I'm doing helps, I'm trying to find the maximal points in a set of sinusoidal graphs with varying amplitudes.

Lamb-Blaster 4000
Sep 20, 2007

delete me

Lamb-Blaster 4000 fucked around with this message at 04:49 on Jun 12, 2008

nolen
Apr 4, 2004

butts.

nolen posted:

I asked this in the Flash Questions thread but it's not really Flash-specific.

Does anyone have experience writing an FTP client? I'm trying to create a proof-of-concept in actionscript that uses binary sockets to connect to the server.


I can get it connected and logged in, but I'm having problems with commands like LIST and PUT. Research tells me it has something to do with being in PASSIVE mode, or that FTP uses one connection for control and another for data.

Can anyone shed some light on this for me, please?

Anyone?

Lamb-Blaster 4000
Sep 20, 2007

ftp passive mode is just that- port 21 is for connection then it picks a random port within a specified range for data, or vice versa, I only remember that much from setting up an ftp server at home.

by setting up I mean installing filezilla.

check out http://en.wikipedia.org/wiki/File_Transfer_Protocol for a low down on some ideas about why your implementation may not be working.

I know that I had a lot of problems with certain ftp clients getting angry about passive and no passive.

This is probably basic stuff- but make sure if you're in passive, that the port range for passive is open and forwarded as well as port 21

nolen
Apr 4, 2004

butts.

Dog Named Duke posted:

ftp passive mode is just that- port 21 is for connection then it picks a random port within a specified range for data, or vice versa, I only remember that much from setting up an ftp server at home.

by setting up I mean installing filezilla.

check out http://en.wikipedia.org/wiki/File_Transfer_Protocol for a low down on some ideas about why your implementation may not be working.

I know that I had a lot of problems with certain ftp clients getting angry about passive and no passive.

This is probably basic stuff- but make sure if you're in passive, that the port range for passive is open and forwarded as well as port 21

Yeah, I can set the mode to passive then parse the IP and port that it returns. I guess I'm just confused about if I'm supposed to open another socket using that IP and port combination and then send my LIST and whatever commands over that socket instead of the control socket that's originally created.

If so, my way of doing it isn't working.

Adbot
ADBOT LOVES YOU

Montalvo
Sep 3, 2007



Fun Shoe

Montalvo posted:

So this a Fortran 95 question. I've got a data file with about 4 columns of 50000 entries consisting of numbers each. I want my code to scan through lines 30000 - 35000 of column 4 and find the highest entry there. How exactly would I go about doing this?

Sorry if this is a basic question, but I'm pretty new to this coding business. :shobon:

Hang on; can't I just feed the values into an array and then use the maxval(array) command?

Edit: this seems to have worked. I get a data set out of the code, but I'm not sure if it shows the right thing. Either way, it's something!

Montalvo fucked around with this message at 12:27 on Jun 12, 2008

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply