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
covener
Jan 10, 2004

You know, for kids!

Mustach posted:

Whoah, outside? What kind of language-warring programmer goes out there?

Obligatory jargon file link: The Big Room

Adbot
ADBOT LOVES YOU

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

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.

covener
Jan 10, 2004

You know, for kids!

Free Bees posted:

I wrote a script in Ruby where I tried to do some Unix-style forking but it didn't run on my Windows machine. I found out that Windows doesn't support forking, but it must have something similar. What is it and how do I use it in Ruby?

Any API provided by your scripting language would be using CreateProcess/CreateProcessEX under the covers -- you shouldn't have to deal with that in your ruby code.

covener
Jan 10, 2004

You know, for kids!

Clock Explosion posted:

and that Java won't let you bind to port 80, they don't notice each other's presence, and thus, the server just stays still, no matter what you do on the HTML page.

java can bind to port 80 just fine. Your java server running on some high port isn't going to "notice" connections hitting some webserver on the same system unless you explicitly connect to it.

quote:

If you need to use sockets on odd ports, I think your only options are PHP(or some other language that you can run server-side like Perl) or a Java applet(which will basically run like poo poo).

the applet security context doesn't permit outgoing tcp connections to other hosts/ports.

covener
Jan 10, 2004

You know, for kids!

Wardhog posted:


I'm writing a bash shell script that is trying to break up a string into two components.
...

filename=`echo ${data} | sed 's/.*\\\//'`

will reliably retrieve the filename in the case of a Windows-style filename. However, I'm drawing a blank as to the best, most efficient way of capturing the prepended directory into a variable.
Can anyone offer any solutions/advice?

since you already have filename, you can just lop it off:

dirname=${data%$filename}

covener
Jan 10, 2004

You know, for kids!

Wardhog posted:

You haven't exactly solved my problem, as dirname won't handle Windows-style filenames, but you've suggested another course of action that's looking promising.

Thanks!

dirname won't cope with c:\aaa\bbb\ccc\ddd\eee
but it WILL cope with c:/aaa/bbb/ccc/ddd/eee and sed is pretty good at changing all occurrences of \ to / and back again

I didn't mean /usr/bin/dirname, just chose a variable that matches your "filename":

code:
$ data='c:\foo\bar\baz.txt'
$ filename=baz.txt
$ echo ${data%$filename}
c:\foo\bar\

covener
Jan 10, 2004

You know, for kids!

Lexical Unit posted:



The question is, why do none of the 32 bit .so files on my machine have these symbolic links setup, but the 64 bit .so files do? I'm guessing that's just the default since the machine is 64 bit.

Doesn't appear to be the case on 64-bit RHEL5/em64t or 64-bit SLES9/ppc64(I don't have a 64-bit RHEL4 running unfortunately).

Net, I believe the symlinks should be there for a _typical_ library. Do you have symlinks for zlib or expat?

covener
Jan 10, 2004

You know, for kids!

Chib posted:

In a Perl regular expression, do you need to escape character a forward slash?

If you use something other then / as your delimiter, you can use / as a literal

foo =~ m@/foo/bar@/a/b/c@;

Note that foo =~ /foo/bar/ is shorthand for m/foo/bar/, but he 'm' becomes mandatory if you pick a different delimiter.

covener
Jan 10, 2004

You know, for kids!

mistermojo posted:

In a C Shell script, how do I output stdout and stderr to a text file (appending it) and display it in the terminal at the same time?

For my program create_images I had

create_images | tee -a log.txt

but that gave me some kind of weird looping thing where it had an error even though the program itself was fine


edit: googling around, I guess I'm running my create_images program, and the error is that I don't have any other inputs. But then what am I supposed to put in the beginning?

for original issue, create_images 2>&1 | tee -a log.txt is a somewhat common idiom. This sends stderr to the same file descriptor as stdout (that tee is already reading).

For your followup, create_images is likely waiting for data on stdin -- are you supposed to invoke it with any positional arguments, or feed it data via stdin?

a guess about your symptom and how your app wants input:
code:
create_images < input.txt 2>&1 | tee -a log.txt

covener
Jan 10, 2004

You know, for kids!

BDA7DD posted:

Nope, that didn't work. It worked so far as that it can now understand what $SRCDIR is, but now the problem is with the $DEFAULTS variable, the script treats it as one single string in the for loop, rather than treating each item separately. I tried removing the escape sequences, still did the same thing. I even tried putting the items in $DEFAULTS into a separate file, newline-separated, and had the script $(cat defaults), $(cat "defaults") and "$(cat defaults)", none of which do what I want them to.

Please help me fix my lovely syntax, I'm bound to understand it once I actually learn it. Sorry if my obsessive overuse of variables is making the script harder to read, I've done that intentionally so that I can make derivative scripts for other OSes once this one's actually working.

Not sure why your separate file didn't work. You should start with smaller, simpler scripts that just echo values -- the script you pastebinned is not in good shape at all.

You might find the "IFS" documentation for your shell helpful, or use arrays instead of worrying about the tokenizing.

deskchecked array example:
code:
-SRCDIR="/mnt/win/Documents\ and\ Settings"
-DEFAULTS="My\ Documents Favorites Application\ Data Local\ Settings Desktop Templates"
+SRCDIR="/mnt/win/Documents and Settings"
+declare -a DEFAULTS
+DEFAULTS=("My Documents" Favorites "Application Data" "Local  Settings" Desktop Templates)
 CLIENT=$1
 EXTRALIST=$2
 BKROOT="/mnt/enc/bk/$CLIENT"
@@ -28,13 +29,14 @@
 mkdir -p $BKROOT/default/
 
 # OH NO, THIS PART DOESN'T WORK!
-for USER in $(ls -Ab --indicator-style=none $SRCDIR/); do
-        for BKDIR in $DEFAULTS; do
-                echo "Copying $BKDIR..." | sed -e "s/\\\ /\ /g"
-                echo cp -a $SRCDIR/$USER/$BKDIR/ $BKROOT/default/$USER/$BKDIR/
+for USER in $SRCDIR/*; do
+        for ((i = 0; i< ${#DEFAULTS}; i++)); do
+                BKDIR=${DEFAULTS[i]}
+                echo "Copying $BKDIR..." 
+                echo cp -a "$SRCDIR/$USER/$BKDIR/" "$BKROOT/default/$USER/$BKDIR/"
         done
 done

covener
Jan 10, 2004

You know, for kids!

MrMoo posted:

There is no need at all unless you are moving to IA64.

OP is on Solaris. Most scrap Solaris hardware is 64-bit capable.

covener
Jan 10, 2004

You know, for kids!

tef posted:

is there a tee equivilent in the shell you are using?

FWIW a native tee.exe is included in http://unxutils.sourceforge.net/.

Not sure it's applicable to cmd.exe, but watch out for changing the exit code of your pipeline with tee.

covener
Jan 10, 2004

You know, for kids!

fletcher posted:

You could do it with a regex but most languages have a URL class to assist with something like this, you may want to look for one.

Any built-in is going to have a hard time with this notion of a "base site" being some substring of the domain/host.

edit: using it at least getting down to to the hostname with a URL class makes perfect sense, didn't intend to criticise your specific followup.

covener fucked around with this message at 02:10 on Oct 24, 2009

covener
Jan 10, 2004

You know, for kids!

Alcool Tue posted:

Perhaps the stupidest question yet posed:

I've been struggling with what seems like it should be a really simple script, basically i want a launcher on my desktop/quick launch bar in ubuntu which will a. open a new bash terminal and then b. have this new terminal execute the command 'cd /***' after opening(or any command, really, but that's for later).

Invoking gnome-terminal via a script is obviously easy, but I'll be damned if I can figure out how to push commands to it, < or > or | would seem to hold the answer, but I've run out of things to try with them. h;alp.

not so sure what you're expecting, but here's 3 things to play with

code:
gnome-terminal -e 'bash -c "cd /***"'
gnome-terminal -e 'bash -c "/your/script.sh"'
(cd /*** &&  gnome-terminal -e 'bash')

covener
Jan 10, 2004

You know, for kids!

shrughes posted:

If it's a hash of a filename you could probably reverse it, unless it's a weirdly long and peculiar filename.

Can you elaborate on what you mean here? Do you just mean by guessing hash algorithms and cycling through filenames to see if you can generate a match?

covener
Jan 10, 2004

You know, for kids!

TheGopher posted:

I know basic C concepts. Stuff like pointers, arrays, defining classes, typecasting, etc. Basic stuff. I have no idea where to go from here. To be clear, C is the only language I'm familiar with. I could probably get to the same point with another language with minimal effort because I really understand what I've been taught.

TheGopher posted:

CarlH (the author of those tutorials) wrote some pretty comprehensive information about programming.

If you're about 8 hours into "learning C in 24 hours", you can't really make that call.

covener
Jan 10, 2004

You know, for kids!
code:
seq -f "%010.0f" 0 9999999999
I shrunk the size by 1000x and discarded the output and it was about 8 seconds.

covener
Jan 10, 2004

You know, for kids!

Jam2 posted:

How do I fix this error? I have gcc 4.2.1 installed.

unable to execute gcc-4.0: No such file or directory

error: command 'gcc-4.0' failed with exit status 1

Looking in my /usr/bin/, I do not have gcc-4.0 installed. What next?

Make sure you don't have environment variable "CC" set to gcc-4.0. Just unset it, and find the dot-file it was set in, rather than replacing the value.

covener
Jan 10, 2004

You know, for kids!

Munkeymon posted:

Alright, I'm not sure where this goes, so I'll just put it here and hopefully it'll get seen.

Some emails were sent containing page.php?key=<number> and, for some reason, a bunch of users are having trouble with the ? getting auto-mangled into %3f when they click on the links in their email clients. I'm trying to come up with a quick server-side fix for this using RewriteRule, but none of these are matching:

code:
RewriteRule ^page.php%3fkey=(.*) /page.php?key=$1
RewriteRule ^page.php%3Fkey=(.*) /page.php?key=$1
RewriteRule ^page.php\%3fkey=(.*) /page.php?key=$1
RewriteRule ^page.php\%3Fkey=(.*) /page.php?key=$1
RewriteRule ^page.php\?key=(.*) /page.php?key=$1
And the File Does Not Exist message is getting written to the error log.

I confirm that the last one ought to match, unless you're confused about what you're getting over the wire. If these rules are in <virtualhost> context,and not htaccess/Directory, the anchor is wrong since what you're matching against will always start with a slash (you can just add it the slash)

covener
Jan 10, 2004

You know, for kids!

Munkeymon posted:

It's not in <virualhost>. I think the problem may be that my test machine is Windows so ? just isn't a valid character in a path because when I do this:
code:
RewriteCond %{QUERY_STRING} (.*)
RewriteRule .* thisExists.htm?%1

RewriteCond %{QUERY_STRING} ^$
RewriteRule .* soDoesThis.html
I still get a server error. Gonna see if I can find a better test environment.

I'm not entirely clear on the applicability of this to the original problem, in this context the bare ? would terminate the URL-path and start the substituted query string.

Perhaps the common thread is that you have some windows specific thing blowing up long before htaccess rewritess can even be processed due to the invalid URI->FS mapping.

In that case, you should move your rewrites out of htaccess/Directory and into VirtualHost context -- they run earlier there in the Apache API. Fix the anchor and tack on a PT flag as well.

covener
Jan 10, 2004

You know, for kids!

Munkeymon posted:

We don't use virtual hosts by decree from on high, so I'm not even going to try setting one up for a test.

The equivalent to VH context in that case would simply be at the bottom of your apache configuration, not inside any other context -- which acts as like a catch-all vhost. This would get your rules running earlier.

covener
Jan 10, 2004

You know, for kids!

Strong Sauce posted:

Edit: OK nevermind, I think I mean the normal console version of vim in Windows. Seems gVim works but vim messes up the colors. Anyone know why vim isn't getting it right but gVim is?

try in a better console, like the native rxvt from cygwin?

covener
Jan 10, 2004

You know, for kids!

The Gripper posted:

Agreed, if the server crashed it wasn't because of the scrape. Downloading 5000 images is not a huge load by any means, and from your description it sounds like you were requesting one image at a time which wouldn't even put a noticeable load on the server.

A better question is "if there was total data loss, how does he still have the HTTP logs?".

and "how many images were downloaded over the previous 10 days, and the next 10?"

covener
Jan 10, 2004

You know, for kids!

Illusive gently caress Man posted:

Not exactly a programming question, but how do people go about getting their head around large open source projects? Is there an IDE that can help me somehow? It's a little difficult when I just want to find out where a function is called from, or where a function/variable/constant is declared/defined and it seems like the only way is to either debug it and look at the call stack in gdb, or to open every single #include and 'find in all open files'

I'd suggest checking out a a quick cscope howto.

Adbot
ADBOT LOVES YOU

covener
Jan 10, 2004

You know, for kids!

DholmbladRU posted:

code:
Listen 882
...
Listen 882
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:882
no listening sockets available, shutting down
AH00015: Unable to open logs

You should only have 1 Listen for that port. Apache doesn't track/merge them to avoid trying to bind twice to the same port. You get the same error as if some other service was already bound to that port

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