Search Results

Search found 84 results on 4 pages for 'crlf'.

Page 1/4 | 1 2 3 4  | Next Page >

  • Getting Excel to handle CRLF's correctly in CSV

    - by Ben Fulton
    I am creating CSV files to be opened in Excel. The rows are separated by CRLF and that's fine, but some of the input data contains CRLF data in it as well. Per the usual standards, I surround them with quotes, but Excel doesn't seem to recognize the CR character and puts a little box with a question mark in it instead. I can strip the CR's out of the CSV file, but it seems like an unnecessary step. Is there an easy way to get Excel to recognize a CRLF inside a row of a CSV file?

    Read the article

  • editing a file with vim that has no EOL marker on the last line but has CRLF line endings

    - by rmeador
    I often have to edit script files, the interpreter for which treats files that have an EOL marker on the last line of the file as an error (i.e. the file is treating CRLF as "newlines", not as "line endings"). Currently, I open these files in Vim using binary mode (-b on the command line). It autodetects the lack of EOL on the final line and sets the "noeol" option appropriately, which prevents it from writing an EOL on the last line. Because the file has CRLF line endings, I get lots of ^Ms at the end of my lines (because it interprets only Unix-style line endings in binary mode, it seems). I can't open it in text mode because the "noeol" option is ignored for non-binary files. This is very annoying, and I always have to remember to manually type the ^M at the end of each line! Is there some way I can force it to accept DOS-style line endings in binary mode, or force it to listen to the EOL option in text mode?

    Read the article

  • Remove windows line endings (crlf) on basic windows 7 install?

    - by Marc K
    Is there a way to remove windows line endings on a basic windows 7 install. I'm working on a windows 7 computer with notepad and word 2010 at work. I'm trying to demo markdown without installing additional text editor, and keeping it installed locally. I've tried Word with replace on \r\n, special characters and other ways and it can't locate. Notepad same issue. Or is there a markdown converter that an online markdown converter that will handle windows line endings?

    Read the article

  • File IO, Handling CRLF

    - by aCuria
    Hi, i am writing a program that takes a file and splits it up into multiple small files of a user specified size, then join the multiple small files back again. 1) the code must work for c, c++ 2) i am compiling with multiple compilers. I am reading and writing to the files by using the stl functions fread() and fwrite() The problem I am having pertains to CRLF. If the file I am reading from contains CRLF, then I want to retain it when i split and join the files back together. If the file contains LF, then i want to retain LF. Unfortunately, fread() seems to store CRLF as \n (I think), and whatever is written by fwrite() is compiler-dependent. How do i approach this problem? Thanks.

    Read the article

  • Biztalk Flat File Schema - how to accept a LF or CRLF as the line delimiter

    - by FullOfQuestions
    Hi, Our client sends us a flat file as input, which we then take and convert to an XML file before sending to the destination system. The flat file consists of multiple lines, each line is delimited by LF or CRLF. How do I create a Flat File Schema so that Biztalk can interpret each line of data regardless of whether the line was delimited by LF (0x0A) or CRLF (0x0D 0x0A)? Thank you in advance, M

    Read the article

  • Blank Mail from PHP application

    - by brettlwilliams
    Problem: Blank email from PHP web application. Confirmed: App works in Linux, has various problems in Windows server environment. Blank emails are the last remaining problem. PHP Version 5.2.6 on the server I'm a librarian implementing a PHP based web application to help students complete their assignments.I have installed this application before on a Linux based free web host and had no problems. Email is controlled by two files, email_functions.php and email.php. While email can be sent, all that is sent is a blank email. My IT department is an ASP only shop, so I can get little to no help there. I also cannot install additional libraries like PHPmail or Swiftmailer. You can see a functional copy at http://rpc.elm4you.org/ You can also download a copy from Sourceforge from the link there. Thanks in advance for any insight into this! email_functions.php <?php /********************************************************** Function: build_multipart_headers Author: Michael Berkowski Last Modified: September 2007 *********************************************************** Purpose: Creates email headers for a message of type multipart/mime This will include a plain text part and HTML. **********************************************************/ function build_multipart_headers($boundary_rand) { global $EMAIL_FROM_DISPLAY_NAME, $EMAIL_FROM_ADDRESS, $CALC_PATH, $CALC_TITLE, $SERVER_NAME; // Using \n instead of \r\n because qmail doubles up the \r and screws everything up! $crlf = "\n"; $message_date = date("r"); // Construct headers for multipart/mixed MIME email. It will have a plain text and HTML part $headers = "X-Calc-Name: $CALC_TITLE" . $crlf; $headers .= "X-Calc-Url: http://{$SERVER_NAME}/{$CALC_PATH}" . $crlf; $headers .= "MIME-Version: 1.0" . $crlf; $headers .= "Content-type: multipart/alternative;" . $crlf; $headers .= " boundary=__$boundary_rand" . $crlf; $headers .= "From: $EMAIL_FROM_DISPLAY_NAME <$EMAIL_FROM_ADDRESS>" . $crlf; $headers .= "Sender: $EMAIL_FROM_DISPLAY_NAME <$EMAIL_FROM_ADDRESS>" . $crlf; $headers .= "Reply-to: $EMAIL_FROM_DISPLAY_NAME <$EMAIL_FROM_ADDRESS>" . $crlf; $headers .= "Return-Path: $EMAIL_FROM_DISPLAY_NAME <$EMAIL_FROM_ADDRESS>" . $crlf; $headers .= "Date: $message_date" . $crlf; $headers .= "Message-Id: $boundary_rand@$SERVER_NAME" . $crlf; return $headers; } /********************************************************** Function: build_multipart_body Author: Michael Berkowski Last Modified: September 2007 *********************************************************** Purpose: Builds the email body content to go with the headers from build_multipart_headers() **********************************************************/ function build_multipart_body($plain_text_message, $html_message, $boundary_rand) { //$crlf = "\r\n"; $crlf = "\n"; $boundary = "__" . $boundary_rand; // Begin constructing the MIME multipart message $multipart_message = "This is a multipart message in MIME format." . $crlf . $crlf; $multipart_message .= "--{$boundary}{$crlf}Content-type: text/plain; charset=\"us-ascii\"{$crlf}Content-Transfer-Encoding: 7bit{$crlf}{$crlf}"; $multipart_message .= $plain_text_message . $crlf . $crlf; $multipart_message .= "--{$boundary}{$crlf}Content-type: text/html; charset=\"iso-8859-1\"{$crlf}Content-Transfer-Encoding: 7bit{$crlf}{$crlf}"; $multipart_message .= $html_message . $crlf . $crlf; $multipart_message .= "--{$boundary}--$crlf$crlf"; return $multipart_message; } /********************************************************** Function: build_step_email_body_text Author: Michael Berkowski Last Modified: September 2007 *********************************************************** Purpose: Returns a plain text version of the email body to be used for individually sent step reminders **********************************************************/ function build_step_email_body_text($stepnum, $arr_instructions, $dates, $query_string, $teacher_info ,$name, $class, $project_id) { global $CALC_PATH, $CALC_TITLE, $SERVER_NAME; $step_email_body =<<<BODY $CALC_TITLE Step $stepnum: {$arr_instructions["step$stepnum"]["title"]} Name: $name Class: $class BODY; $step_email_body .= build_text_single_step($stepnum, $arr_instructions, $dates, $query_string, $teacher_info); $step_email_body .= "\n\n"; $step_email_body .=<<<FOOTER The $CALC_TITLE offers suggestions, but be sure to check with your teacher to find out the best working schedule for your assignment! If you would like to stop receiving further reminders for this project, click the link below: http://$SERVER_NAME/$CALC_PATH/deleteproject.php?proj=$project_id FOOTER; // Wrap text to 78 chars per line // Convert any remaining HTML <br /> to \r\n // Strip out any remaining HTML tags. $step_email_body = strip_tags(linebreaks_html2text(wordwrap($step_email_body, 78, "\n"))); return $step_email_body; } /********************************************************** Function: build_step_email_body_html Author: Michael Berkowski Last Modified: September 2007 *********************************************************** Purpose: Same as above, but with HTML **********************************************************/ function build_step_email_body_html($stepnum, $arr_instructions, $dates, $query_string, $teacher_info, $name, $class, $project_id) { global $CALC_PATH, $CALC_TITLE, $SERVER_NAME; $styles = build_html_styles(); $step_email_body =<<<BODY <html> <head> <title> $CALC_TITLE </title> $styles </head> <body> <h1> $CALC_TITLE Schedule </h1> <strong>Name:</strong> $name <br /> <strong>Class:</strong> $class <br /> BODY; $step_email_body .= build_html_single_step($stepnum, $arr_instructions, $dates, $query_string, $teacher_info); $step_email_body .=<<<FOOTER <p> The $CALC_TITLE offers suggestions, but be sure to check with your teacher to find out the best working schedule for your assignment! </p> <p> If you would like to stop receiving further reminders for this project, <a href="http://{$SERVER_NAME}/$CALC_PATH/deleteproject.php?proj=$project_id">click this link.</a> </p> </body> </html> FOOTER; return $step_email_body; } /********************************************************** Function: build_html_styles Author: Michael Berkowski Last Modified: September 2007 *********************************************************** Purpose: Just returns a string of <style /> for the HTML message body **********************************************************/ function build_html_styles() { $styles =<<<STYLES <style type="text/css"> body { font-family: Arial, sans-serif; font-size: 85%; } h1 { font-size: 120%; } table { border: none; } tr { vertical-align: top; } img { display: none; } hr { border: 0; } </style> STYLES; return $styles; } /********************************************************** Function: linebreaks_html2text Author: Michael Berkowski Last Modified: October 2007 *********************************************************** Purpose: Convert <br /> html tags to \n line breaks **********************************************************/ function linebreaks_html2text($in_string) { $out_string = ""; $arr_br = array("<br>", "<br />", "<br/>"); $out_string = str_replace($arr_br, "\n", $in_string); return $out_string; } ?> email.php <?php require_once("include/config.php"); require_once("include/instructions.php"); require_once("dbase/dbfunctions.php"); require_once("include/email_functions.php"); ini_set("sendmail_from", "[email protected]"); ini_set("SMTP", "mail.qatar.net.qa"); // Verify that the email has not already been sent by checking for a cookie // whose value is generated each time the form is loaded freshly. if (!(isset($_COOKIE['rpc_transid']) && $_COOKIE['rpc_transid'] == $_POST['transid'])) { // Setup some preliminary variables for email. // The scanning of $_POST['email']already took place when this file was included... $to = $_POST['email']; $subject = $EMAIL_SUBJECT; $boundary_rand = md5(rand()); $mail_type = ""; switch ($_POST['reminder-type']) { case "progressive": $arr_dbase_dates = array(); $conn = rpc_connect(); if (!$conn) { $mail_success = FALSE; $mail_status_message = "Could not register address!"; break; } // Sanitize all the data that will be inserted into table... // We need to remove "CONTENT-TYPE:" from name/class to defang them. // Additionall, we can't allow any line-breaks in those fields to avoid // hacks to email headers. $ins_name = mysql_real_escape_string($name); $ins_name = eregi_replace("CONTENT-TYPE", "...Content_Type...", $ins_name); $ins_name = str_replace("\n", "", $ins_name); $ins_class = mysql_real_escape_string($class); $ins_class = eregi_replace("CONTENT-TYPE", "...Content_Type...", $ins_class); $ins_class = str_replace("\n", "", $ins_class); $ins_email = mysql_real_escape_string($email); $ins_teacher_info = $teacher_info ? "YES" : "NO"; switch ($format) { case "Slides": $ins_format = "SLIDES"; break; case "Video": $ins_format = "VIDEO"; break; case "Essay": default: $ins_format = "ESSAY"; break; } // The transid from the previous form will be used as a project identifier // Steps will be grouped by project identifier. $ins_project_id = mysql_real_escape_string($_POST['transid'] . md5(rand())); $arr_dbase_dates = dbase_dates($dates); $arr_past_dates = array(); // Iterate over the dates array and build a SQL statement for each one. $insert_success = TRUE; // $min_reminder_date = date("Ymd", mktime(0,0,0,date("m"),date("d")+$EMAIL_REMINDER_DAYS_AHEAD,date("Y"))); for ($date_index = 0; $date_index < sizeof($arr_dbase_dates); $date_index++) { // Make sure we're using the right keys... $ins_date_index = $date_index + 1; // The insert will only happen if the date of the event is in the future. // For dates today and earlier, no insert. // For dates today or after the reminder deadline, we'll send the email immediately after the inserts. if ($arr_dbase_dates[$date_index] > (int)$min_reminder_date) { $qry =<<<QRY INSERT INTO email_queue ( NOTIFICATION_ID, PROJECT_ID, EMAIL, NAME, CLASS, FORMAT, TEACHER_INFO, STEP, MESSAGE_DATE ) VALUES ( NULL, '$ins_project_id', '$ins_email', '$ins_name', '$ins_class', '$ins_format', '$ins_teacher_info', $ins_date_index, /*step number*/ {$arr_dbase_dates[$date_index]} /* Date in the integer format yyyymmdd */ ) QRY; // Attempt to do the insert... $result = mysql_query($qry); // If even one insert fails, bail out. if (!$result) { $mail_success = FALSE; $mail_status_message = "Could not register address!"; break; } } // For dates today or earlier, store the steps=>dates in an array so the mails can // be sent immediately. else { $arr_past_dates[$ins_date_index] = $arr_dbase_dates[$date_index]; } } // Close the connection resources. mysql_close($conn); // SEND OUT THE EMAILS THAT HAVE TO GO IMMEDIATELY... // This should only be step 1, but who knows... //var_dump($arr_past_dates); for ($stepnum=1; $stepnum<=sizeof($arr_past_dates); $stepnum++) { $email_teacher_info = ($teacher_info && $EMAIL_TEACHER_REMINDERS) ? TRUE : FALSE; $boundary = md5(rand()); $plain_text_body = build_step_email_body_text($stepnum, $arr_instructions, $dates, $query_string, $email_teacher_info ,$name, $class, $ins_project_id); $html_body = build_step_email_body_html($stepnum, $arr_instructions, $dates, $query_string, $email_teacher_info ,$name, $class, $ins_project_id); $multipart_headers = build_multipart_headers($boundary); $multipart_body = build_multipart_body($plain_text_body, $html_body, $boundary); mail($to, $subject . ": Step " . $stepnum, $multipart_body, $multipart_headers, "[email protected]"); } // Set appropriate flags and messages $mail_success = TRUE; $mail_status_message = "Email address registered!"; $mail_type = "progressive"; set_mail_success_cookie(); break; // Default to a single email message. case "single": default: // We don't want to send images in the message, so strip them out of the existing structure. // This big ugly regex strips the whole table cell containing the image out of the table. // Must find a better solution... //$email_table_html = eregi_replace("<td class=\"stepImageContainer\" width=\"161px\">[\s\r\n\t]*<img class=\"stepImage\" src=\"images/[_a-zA-Z0-9]*\.gif\" alt=\"Step [1-9]{1} logo\" />[\s\r\n\t]*</td>", "\n", $table_html); // Show more descriptive text based on the value of $format switch ($format) { case "Video": $format_display = "Video"; break; case "Slides": $format_display = "Presentation with electronic slides"; break; case "Essay": default: $format_display = "Essay"; break; } $days = (int)$days; $html_message = ""; $styles = build_html_styles(); $html_message =<<<HTMLMESSAGE <html> <head> <title> $CALC_TITLE </title> $styles </head> <body> <h1> $CALC_TITLE Schedule </h1> <strong>Name:</strong> $name <br /> <strong>Class:</strong> $class <br /> <strong>Email:</strong> $email <br /> <strong>Assignment type:</strong> $format_display <br /><br /> <strong>Starting on:</strong> $date1 <br /> <strong>Assignment due:</strong> $date2 <br /> <strong>You have $days days to finish.</strong><br /> <hr /> $email_table_html </body> </html> HTMLMESSAGE; // Create the plain text version of the message... $plain_text_message = strip_tags(linebreaks_html2text(build_text_all_steps($arr_instructions, $dates, $query_string, $teacher_info))); // Add the title, since it doesn't get built in by build_text_all_steps... $plain_text_message = $CALC_TITLE . " Schedule\n\n" . $plain_text_message; $plain_text_message = wordwrap($plain_text_message, 78, "\n"); $multipart_headers = build_multipart_headers($boundary_rand); $multipart_message = build_multipart_body($plain_text_message, $html_message, $boundary_rand); $mail_success = FALSE; if (mail($to, $subject, $multipart_message, $multipart_headers, "[email protected]")) { $mail_success = TRUE; $mail_status_message = "Email sent!"; $mail_type = "single"; set_mail_success_cookie(); } else { $mail_success = FALSE; $mail_status_message = "Could not send email!"; } break; } } function set_mail_success_cookie() { // Prevent the mail from being resent on page reload. Set a timestamp cookie. // Expires in 24 hours. setcookie("rpc_transid", $_POST['transid'], time() + 86400); } ?>

    Read the article

  • Remove CR LF for all lines that are not followed by a specific number

    - by Kjeldsen
    I have 14000+ lines of a database, that I want to edit with Notepad++. All these lines should start with 1000 and I therefore want to delete CR LF at the end of those lines that are not followed by 1000. Eg. 1000 16 04000 CRLF sdfsdf 15 sdf de 05550 CRLF 1000 16 04000 CRLF 1000 16 04000 CRLF 5. sdkfd dksds 16 0555 CRLF 10/10/14 sdfsdf CRLF should after find and replace look like 1000 16 04000 sdfsdf 15 sdf de 05550 CRLF 1000 16 04000 CRLF 1000 16 04000 5. sdkfd dksds 16 0555 10 sdfsdf CRLF I have tried with find what: \r\n([^1000]) Replace with _\1 However, this doesn't seem to remove lines starting with a number (like 5. or 10/10/14). Is it possible to make just one RegEx to find and remove all line breaks that isn't followed by 1000? "_" indicating a "space"

    Read the article

  • Question about POP3 message termination octet

    - by user361633
    This is from the POP3 RFC. "Responses to certain commands are multi-line. In these cases, which are clearly indicated below, after sending the first line of the response and a CRLF, any additional lines are sent, each terminated by a CRLF pair. When all lines of the response have been sent, a final line is sent, consisting of a termination octet (decimal code 046, ".") and a CRLF pair. If any line of the multi-line response begins with the termination octet, the line is "byte-stuffed" by pre-pending the termination octet to that line of the response. Hence a multi-line response is terminated with the five octets "CRLF.CRLF". When examining a multi-line response, the client checks to see if the line begins with the termination octet. If so and if octets other than CRLF follow, the first octet of the line (the termination octet) is stripped away. If so and if CRLF immediately follows the termination character, then the response from the POP server is ended and the line containing ".CRLF" is not considered part of the multi-line response." Well, i have problem with this, for example gmail sometimes sends the termination octet and then in the NEXT LINE sends the CRLF pair. For example: "+OK blah blah" "blah blah." "\r\n" That's very rare, but it happens sometimes, so obviously i'm unable to determine the end of the message in such case, because i'm expecting a line that consists of '.\r\n'. Seriously, is Gmail violating the POP3 protocol or i'm doing something wrong? Also i have a second question, english is not my first language so i cannot understand that completely: "If any line of the multi-line response begins with the termination octet, the line is "byte-stuffed" by pre-pending the termination octet to that line of the response. Hence a multi-line response is terminated with the five octets "CRLF.CRLF"." When exactly CRLF.CRLF is used? Can someone gives me a simple example? The rfc says that is used when any line of the response begins with the termination octet. But i don't see any lines that starts with '.' in the messages that are terminated with CRLF.CRLF. I checked that. Maybe i don't understand something, that's why i'm asking.

    Read the article

  • git crlf configuration in mixed environment

    - by Jonas Byström
    I'm running a mixed environment, and keep a central, bare repository where I pull and push most of my stuff. This centralized repository runs on Linux, and I check out to Windows XP/7, Mac and Linux. In all repositories I put the following line in my .git/config: [core] autocrlf = true I don't have the flag safecrlf=true anywhere. First time when I modify stuff on my one Windows machine (XP) there is no problem and when I look at the diff, it looks fine. But when I do the same on the other Windows machine (7), all lines are shown as changed but local line endings are \r\n as expected (when checked in a hex editor). The same applies to a MacOSX can. Sometimes I get the feeling that the different systems wrestle on line endings, but I can't be sure (I'm loosing track of all the times I change specific files). I didn't use to have the autocrlf set, but set the flag many months back. Could that be causing my current problems? Do I need to clone everything again to loose some old baggage? Or are there other things that needs configuring too? I tried git checkout -- . about a million times, but with no success.

    Read the article

  • Gratuitous CRLF in Subject: line - why is it there, and is it legal?

    - by MadHatter
    I'm running into a problem with a NAGIOS system sending emails to a popular email-to-SMS service. The email-to-SMS service takes emails with text in the Subject: line, and sends them on to the mobile number encoded in the To: field. So far so good. Sadly, sendmail (and postfix before it) seem to be inserting a gratuitous CRLF into the (necessarily long) Subject: line, and that's causing my SMS messages to be truncated at the CRLF if and only if the Subject: line contains one or more colons past the gratuitous CRLF. I am confident that the messages are being created correctly, but just to be sure, here's me creating a completely noddy test message to myself, with a long Subject: line: echo "foo" | mail -s "1234567 101234567 201234567 301234567 401234567 501234567 601234567 701234567 801234567 90123456789" [email protected] Note there's no extra colon in this Subject: line; all I'm doing here is showing that an extra CRLF is inserted on the wire. Here's the result of sudo ngrep -x port 25: 44 61 74 65 3a 20 46 72    69 2c 20 33 31 20 4d 61    Date: Fri, 31 Ma 79 20 32 30 31 33 20 31    30 3a 34 33 3a 35 35 20    y 2013 10:43:55 2b 30 31 30 30 0d 0a 54    6f 3a 20 72 65 61 70 65    +0100..To: reape 72 40 74 65 61 70 61 72    74 79 2e 6e 65 74 0d 0a    [email protected].. 53 75 62 6a 65 63 74 3a    20 31 32 33 34 35 36 37    Subject: 1234567 20 31 30 31 32 33 34 35    36 37 20 32 30 31 32 33     101234567 20123 34 35 36 37 20 33 30 31    32 33 34 35 36 37 20 34    4567 301234567 4 30 31 32 33 34 35 36 37    20 35 30 31 32 33 34 35    01234567 5012345 36 37 0d 0a 20 36 30 31    32 33 34 35 36 37 20 37    67.. 601234567 7 30 31 32 33 34 35 36 37    20 38 30 31 32 33 34 35    01234567 8012345 36 37 20 39 30 31 32 33    34 35 36 37 38 39 0d 0a    67 90123456789.. 55 73 65 72 2d 41 67 65    6e 74 3a 20 48 65 69 72    User-Agent: Heir 6c 6f 6f 6d 20 6d 61 69    6c 78 20 31 32 2e 34 20    loom mailx 12.4 37 2f 32 39 2f 30 38 0d    0a 4d 49 4d 45 2d 56 65    7/29/08..MIME-Ve 72 73 69 6f 6e 3a 20 31    2e 30 0d 0a 43 6f 6e 74    rsion: 1.0..Cont 65 6e 74 2d 54 79 70 65    3a 20 74 65 78 74 2f 70    ent-Type: text/p 6c 61 69 6e 3b 20 63 68    61 72 73 65 74 3d 75 73    lain; charset=us About half way down (marked in bold+italic), between the 501234567 and the 601234567 in the original Subject: header, you can see a CRLF being inserted (0x0d 0x0a, on the left-hand side hex dump, .. on the right-hand side plain text). The receiving MTA seems happy to post-process this, and when I look at the on-disc stored mail at the receiving end, I see only a LF (0x0a) in the Subject: line, and the line is parsed correctly and in its entirety by, eg, alpine. Nevertheless, the CRLF is there on the wire, and between me and the (excellent) email-to-SMS support people, we've established that these are the cause of the problem. So my question is: is it lawful for an MTA to insert a gratuitous CRLF on the wire? If it is, and I can prove it, then it's the email-to-SMS house's problem, because they are being intolerant. If it isn't, or it is but I can't prove it, then it becomes my problem, so an answer with references would be most useful. Edit: I can now come clean that the email-to-SMS service in question is kapow. Once this problem was explained to them, they got it, worked with me to develop and test a fix, and have deployed the fix. My long subject lines with colons in now get relayed correctly into SMSes. I don't normally trumpet individual companies, especially not on SF, but I thought it worthy of note that kapow Did The Right Thing. (Disclaimer: I have no connection with kapow except as a paying customer who's happy about the way they dealt with his problem.)

    Read the article

  • Powershell overruling Perl binmode?

    - by hippietrail
    I have a Perl script which creates a binary file while scanning a very large text file. It outputs to STDOUT which I redirect in the commandline to a file. To optimize it I'm making changes then seeing how low it takes to run. On Linux for this I use the "time" command. On Windows the best way to time a program seemed to be to PowerShell's "measure-command". This seemed to work fine but I noticed the generated files were larger. On examination I found that the files generated from within PowerShell begin with a BOM and contain CRLF pairs! My Perl script has a "binmode STDOUT" directive and does work correctly in a normal dosbox. Is this a bug or misfeature in PowerShell or measure-command? Has it affected others creating binary files by means other than Perl? Googling hasn't turned anything up so far. I'm using Perl 5.12, PowerShell v1.0 and Windows XP.

    Read the article

  • C# StreamReader.ReadLine() - Need to pick up line terminators

    - by Tony Trozzo
    I wrote a C# program to read an Excel .xls/.xlsx file and output to CSV and Unicode text. I wrote a separate program to remove blank records. This is accomplished by reading each line with StreamReader.ReadLine(), and then going character by character through the string and not writing the line to output if it contains all commas (for the CSV) or all tabs (for the Unicode text). The problem occurs when the Excel file contains embedded newlines (\x0A) inside the cells. I changed my XLS to CSV converter to find these new lines (since it goes cell by cell) and write them as \x0A, and normal lines just use StreamWriter.WriteLine(). The problem occurs in the separate program to remove blank records. When I read in with StreamReader.ReadLine(), by definition it only returns the string with the line, not the terminator. Since the embedded newlines show up as two separate lines, I can't tell which is a full record and which is an embedded newline for when I write them to the final file. I'm not even sure I can read in the \x0A because everything on the input registers as '\n'. I could go character by character, but this destroys my logic to remove blank lines. Any ideas would be greatly appreciated.

    Read the article

  • Access VBA remove CR & LF only from the beginning of a text string by searching for them

    - by uZI
    Hi there I need to remove line breaks from the beginning of a memo type records. I dont want to use the replace function as it would remove all line breaks from the record which is not desired. Its only the line breaks at the beginning of the field that I am interested in removing. Furthermore, the my records do not always begin with a line break so I cant really use text positioning, the solution would be to look for line break at the beginning instead of always expecting it at the beginning. click here for a sample of what my data looks like any help will be greatly appreciated

    Read the article

  • SSMS Results to Grid - CRLF not preserved in copy/paste - any better techniques?

    - by Cade Roux
    When I have a result set in the grid like: SELECT 'line 1 line 2 line 3' or SELECT 'line 1' + CHAR(13) + CHAR(10) + 'line 2' + CHAR(13) + CHAR(10) + 'line 3' With embedded CRLF, the display in the grid appears to replace them with spaces (I guess so that they will display all the data). The problem is that if I am code-generating a script, I cannot simply cut and paste this. I have to convert the code to open a cursor and print the relevant columns so that I can copy and paste them from the text results. Is there any simpler workaround to preserve the CRLF in a copy/paste operation from the results grid? The reason that the grid is helpful is that I am currently generating a number of scripts for the same object in different columns - a bcp out in one column, an xml format file in another, a table create script in another, etc...

    Read the article

  • Perl MiniWebserver

    - by snikolov
    hey guys i have config this miniwebserver, however i require the server to download a file in the local directory i am getting a problem can you please fix my issue thanks !/usr/bin/perl use strict; use Socket; use IO::Socket; my $buffer; my $file; my $length; my $output; Simple web server in Perl Serves out .html files, echos form data sub parse_form { my $data = $_[0]; my %data; foreach (split /&/, $data) { my ($key, $val) = split /=/; $val =~ s/+/ /g; $val =~ s/%(..)/chr(hex($1))/eg; $data{$key} = $val;} return %data; } Setup and create socket my $port = shift; defined($port) or die "Usage: $0 portno\n"; my $DOCUMENT_ROOT = $ENV{'HOME'} . "public"; my $server = new IO::Socket::INET(Proto = 'tcp', LocalPort = $port, Listen = SOMAXCONN, Reuse = 1); $server or die "Unable to create server socket: $!" ; Await requests and handle them as they arrive while (my $client = $server-accept()) { $client-autoflush(1); my %request = (); my %data; { -------- Read Request --------------- local $/ = Socket::CRLF; while (<$client>) { chomp; # Main http request if (/\s*(\w+)\s*([^\s]+)\s*HTTP\/(\d.\d)/) { $request{METHOD} = uc $1; $request{URL} = $2; $request{HTTP_VERSION} = $3; } # Standard headers elsif (/:/) { (my $type, my $val) = split /:/, $_, 2; $type =~ s/^\s+//; foreach ($type, $val) { s/^\s+//; s/\s+$//; } $request{lc $type} = $val; } # POST data elsif (/^$/) { read($client, $request{CONTENT}, $request{'content-length'}) if defined $request{'content-length'}; last; } } } -------- SORT OUT METHOD --------------- if ($request{METHOD} eq 'GET') { if ($request{URL} =~ /(.*)\?(.*)/) { $request{URL} = $1; $request{CONTENT} = $2; %data = parse_form($request{CONTENT}); } else { %data = (); } $data{"_method"} = "GET"; } elsif ($request{METHOD} eq 'POST') { %data = parse_form($request{CONTENT}); $data{"_method"} = "POST"; } else { $data{"_method"} = "ERROR"; } ------- Serve file ---------------------- my $localfile = $DOCUMENT_ROOT.$request{URL}; Send Response if (open(FILE, "<$localfile")) { print $client "HTTP/1.0 200 OK", Socket::CRLF; print $client "Content-type: text/html", Socket::CRLF; print $client Socket::CRLF; my $buffer; while (read(FILE, $buffer, 4096)) { print $client $buffer; } $data{"_status"} = "200"; } else { $file = 'a.pl'; open(INFILE, $file); while (<INFILE>) { $output .= $_; ##output of the file } $length = length($output); print $client "'HTTP/1.0 200 OK", Socket::CRLF; print $client "Content-type: application/octet-stream", Socket::CRLF; print $client "Content-Length:".$length, Socket::CRLF; print $client "Accept-Ranges: bytes", Socket::CRLF; print $client 'Content-Disposition: attachment; filename="test.zip"', Socket::CRLF; print $client $output, Socket::CRLF; print $client 'Content-Transfer-Encoding: binary"', Socket::CRLF; print $client "Connection: Keep-Alive", Socket::CRLF; # #$data{"_status"} = "404"; # } close(FILE); Log Request print ($DOCUMENT_ROOT.$request{URL},"\n"); foreach (keys(%data)) { print (" $_ = $data{$_}\n"); } ----------- Close Connection and loop ------------------ close $client; } END

    Read the article

  • Mercurial push error - hook failed

    - by raychenon
    I committed some changesets. Now I want to push them to remote repository. I get this error during push pushing to http://hguser:***@z2xeu:1337/hg/cms searching for changes 1 changesets found remote: adding changesets remote: adding manifests remote: adding file changes remote: added 1 changesets with 2 changes to 2 files remote: Attempt to commit or push text file(s) using CRLF line endings remote: in 700e14d32918: src/main/webapp/WEB-INF/jsp/search.jsp remote: remote: To prevent this mistake in your local repository, remote: add to Mercurial.ini or .hg/hgrc: remote: remote: [hooks] remote: pretxncommit.crlf = python:hgext.win32text.forbidcrlf remote: remote: and also consider adding: remote: remote: [extensions] remote: hgext.win32text = remote: [encode] remote: ** = cleverencode: remote: [decode] remote: ** = cleverdecode: remote: transaction abort! remote: rollback completed remote: abort: pretxnchangegroup.crlf hook failed [command returned code 1 Wed Jan 12 11:14:55 2011] To prevent this, I wrote in the .hg/hgrc file ( there is no Mercurial.ini ) [hooks] pretxncommit.crlf = python:hgext.win32text.forbidcrlf pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf [extensions] hgext.win32text = But I still get the same error as above. I'm pretty sure pretxnchangegroup.crlf is involved in this, maybe a python file ? I use only unicode characters in files committed

    Read the article

  • When should I use Perl's AUTOLOAD?

    - by Robert S. Barnes
    In "Perl Best Practices" the very first line in the section on AUTOLOAD is: Don't use AUTOLOAD However all the cases he describes are dealing with OO or Modules. I have a stand alone script in which some command line switches control which versions of particular functions get defined. Now I know I could just take the conditionals and the evals and stick them naked at the top of my file before everything else, but I find it convenient and cleaner to put them in AUTOLOAD at the end of the file. Is this bad practice / style? If you think so why, and is there a another way to do it? As per brian's request I'm basically using this to do conditional compilation based on command line switches. I don't mind some constructive criticism. sub AUTOLOAD { our $AUTOLOAD; (my $method = $AUTOLOAD) =~ s/.*:://s; # remove package name if ($method eq 'tcpdump' && $tcpdump) { eval q( sub tcpdump { my $msg = shift; warn gf_time()." Thread ".threads->tid().": $msg\n"; } ); } elsif ($method eq 'loginfo' && $debug) { eval q( sub loginfo { my $msg = shift; $msg =~ s/$CRLF/\n/g; print gf_time()." Thread ".threads->tid().": $msg\n"; } ); } elsif ($method eq 'build_get') { if ($pipelining) { eval q( sub build_get { my $url = shift; my $base = shift; $url = "http://".$url unless $url =~ /^http/; return "GET $url HTTP/1.1${CRLF}Host: $base$CRLF$CRLF"; } ); } else { eval q( sub build_get { my $url = shift; my $base = shift; $url = "http://".$url unless $url =~ /^http/; return "GET $url HTTP/1.1${CRLF}Host: $base${CRLF}Connection: close$CRLF$CRLF"; } ); } } elsif ($method eq 'grow') { eval q{ require Convert::Scalar qw(grow); }; if ($@) { eval q( sub grow {} ); } goto &$method; } else { eval "sub $method {}"; return; } die $@ if $@; goto &$method; }

    Read the article

  • Sending email to gmail account using c++ on windows error check

    - by LCD Fire
    I know this has been disscused a lot, but I I'm not asking how to do it, I'm just asking why it doesn't work. What I am doing wrong. It says that the email was sent succesfully but I don't see it in my inbox. I want to send an email to a gmail account, not through it. #include <iostream> #include <windows.h> #include <fstream> #include <conio.h> #pragma comment(lib, "ws2_32.lib") // Insist on at least Winsock v1.1 const int VERSION_MAJOR = 1; const int VERSION_MINOR = 1; #define CRLF "\r\n" // carriage-return/line feed pair using namespace std; // Basic error checking for send() and recv() functions void Check(int iStatus, char *szFunction) { if((iStatus != SOCKET_ERROR) && (iStatus)) return; cerr<< "Error during call to " << szFunction << ": " << iStatus << " - " << GetLastError() << endl; } int main(int argc, char *argv[]) { int iProtocolPort = 25; char szSmtpServerName[64] = ""; char szToAddr[64] = ""; char szFromAddr[64] = ""; char szBuffer[4096] = ""; char szLine[255] = ""; char szMsgLine[255] = ""; SOCKET hServer; WSADATA WSData; LPHOSTENT lpHostEntry; LPSERVENT lpServEntry; SOCKADDR_IN SockAddr; // Check for four command-line args //if(argc != 5) // ShowUsage(); // Load command-line args lstrcpy(szSmtpServerName, "smtp.gmail.com"); lstrcpy(szToAddr, "[email protected]"); lstrcpy(szFromAddr, "[email protected]"); // Create input stream for reading email message file ifstream MsgFile("D:\\d.txt"); // Attempt to intialize WinSock (1.1 or later) if(WSAStartup(MAKEWORD(VERSION_MAJOR, VERSION_MINOR), &WSData)) { cout << "Cannot find Winsock v" << VERSION_MAJOR << "." << VERSION_MINOR << " or later!" << endl; return 1; } // Lookup email server's IP address. lpHostEntry = gethostbyname(szSmtpServerName); if(!lpHostEntry) { cout << "Cannot find SMTP mail server " << szSmtpServerName << endl; return 1; } // Create a TCP/IP socket, no specific protocol hServer = socket(PF_INET, SOCK_STREAM, 0); if(hServer == INVALID_SOCKET) { cout << "Cannot open mail server socket" << endl; return 1; } // Get the mail service port lpServEntry = getservbyname("mail", 0); // Use the SMTP default port if no other port is specified if(!lpServEntry) iProtocolPort = htons(IPPORT_SMTP); else iProtocolPort = lpServEntry->s_port; // Setup a Socket Address structure SockAddr.sin_family = AF_INET; SockAddr.sin_port = iProtocolPort; SockAddr.sin_addr = *((LPIN_ADDR)*lpHostEntry->h_addr_list); // Connect the Socket if(connect(hServer, (PSOCKADDR) &SockAddr, sizeof(SockAddr))) { cout << "Error connecting to Server socket" << endl; return 1; } // Receive initial response from SMTP server Check(recv(hServer, szBuffer, sizeof(szBuffer), 0), "recv() Reply"); // Send HELO server.com sprintf(szMsgLine, "HELO %s%s", szSmtpServerName, CRLF); Check(send(hServer, szMsgLine, strlen(szMsgLine), 0), "send() HELO"); Check(recv(hServer, szBuffer, sizeof(szBuffer), 0), "recv() HELO"); // Send MAIL FROM: <[email protected]> sprintf(szMsgLine, "MAIL FROM:<%s>%s", szFromAddr, CRLF); Check(send(hServer, szMsgLine, strlen(szMsgLine), 0), "send() MAIL FROM"); Check(recv(hServer, szBuffer, sizeof(szBuffer), 0), "recv() MAIL FROM"); // Send RCPT TO: <[email protected]> sprintf(szMsgLine, "RCPT TO:<%s>%s", szToAddr, CRLF); Check(send(hServer, szMsgLine, strlen(szMsgLine), 0), "send() RCPT TO"); Check(recv(hServer, szBuffer, sizeof(szBuffer), 0), "recv() RCPT TO"); // Send DATA sprintf(szMsgLine, "DATA%s", CRLF); Check(send(hServer, szMsgLine, strlen(szMsgLine), 0), "send() DATA"); Check(recv(hServer, szBuffer, sizeof(szBuffer), 0), "recv() DATA"); //strat writing about the subject, end it with two CRLF chars and after that you can //write data to the body oif the message sprintf(szMsgLine, "Subject: My own subject %s%s", CRLF, CRLF); Check(send(hServer, szMsgLine, strlen(szMsgLine), 0), "send() DATA"); // Send all lines of message body (using supplied text file) MsgFile.getline(szLine, sizeof(szLine)); // Get first line do // for each line of message text... { sprintf(szMsgLine, "%s%s", szLine, CRLF); Check(send(hServer, szMsgLine, strlen(szMsgLine), 0), "send() message-line"); MsgFile.getline(szLine, sizeof(szLine)); // get next line. } while(!MsgFile.eof()); // Send blank line and a period sprintf(szMsgLine, "%s.%s", CRLF, CRLF); Check(send(hServer, szMsgLine, strlen(szMsgLine), 0), "send() end-message"); Check(recv(hServer, szBuffer, sizeof(szBuffer), 0), "recv() end-message"); // Send QUIT sprintf(szMsgLine, "QUIT%s", CRLF); Check(send(hServer, szMsgLine, strlen(szMsgLine), 0), "send() QUIT"); Check(recv(hServer, szBuffer, sizeof(szBuffer), 0), "recv() QUIT"); // Report message has been sent cout<< "Sent " << argv[4] << " as email message to " << szToAddr << endl; // Close server socket and prepare to exit. closesocket(hServer); WSACleanup(); _getch(); return 0; }

    Read the article

  • Why am I getting blank error messages in my Apache error log?

    - by Jason Lamoreux
    I am running Apache 2.2 on 64bit Windows Server 2008 Std edition with ActivePerl 5.8.9. My error log is filling up with blank error messages like these: [Wed Mar 31 14:08:31 2010] [error] [client 10.6.1.164] [Wed Mar 31 14:10:32 2010] [error] [client 10.6.1.89] [Wed Mar 31 14:13:20 2010] [error] [client 10.6.1.131] By looking in the access log I can tell that it occurs when our client machines issue a GET to a very simple Perl script. #!perl.exe use strict; no warnings; $|=1; use CGI::Carp('fatalsToBrowser'); use CGI qw(:standard); print header; my $CRLF = "\r\n<br>"; my $Port = '10116'; print "Success!${CRLF}PollInterval=5${CRLF}LMProMode${CRLF}Version=7${CRLF}ConnectionPort=$Port"; exit; The weird thing is that it does not look like this error message is inserted every time a GET to this Perl script occurs. What could cause this error message to appear in the Apache error log?

    Read the article

  • How to compare two variables from a java class in jess and execute a rule?

    - by user3417084
    I'm beginner in Jess. I'm trying to compare two variables from a Java class in Jess and trying to execute a rule. I have imported cTNumber and measuredCurrent (both are integer)form a java class called CurrentSignal. Similarly imported vTNumberand measuredVoltage form a java class DERSignal. Now I want to make a rule such that if cTNumber is equal to vTNumber then multiply measuredCurrent and measuredVoltage (Both are double) for calculating power. I'm trying in this way.... (import signals.*) (deftemplate CurrentSignal (declare (from-class CurrentSignal))) (deftemplate DERSignal (declare (from-class DERSignal))) (defglobal ?*CTnumber* = 0) (defglobal ?*VTnumber* = 0) (defglobal ?*VTnumberDER* = 0) (defglobal ?*measuredCurrent* = 0) (defglobal ?*measuredVoltage* = 0) (defglobal ?*measuredVoltageDER* = 0) (defrule Get-CT-Number (CurrentSignal (cTNumber ?m)) (CurrentSignal (measuredCurrent ?c)) => (bind ?*measuredCurrent* ?c) (printout t "Measured Current : " ?*measuredCurrent*" Amps"crlf) (bind ?*CTnumber* ?m) (printout t ?*CTnumber* crlf) ) (defrule Get-DER-Number (DERSignal (vTNumber ?o)) (DERSignal (measuredVoltage ?V)) => (bind ?*measuredVoltageDER* ?V) (printout t "Measured Voltage : " ?*measuredVoltageDER* " V" crlf) (bind ?*VTnumberDER* ?o) (printout t ?*VTnumberDER* crlf) ) (defrule Power-Calculation-DER-signal "Power calculation of DER Bay" (test (= ?*CTnumber* ?*VTnumberDER* )) => (printout t "Total Generation : " (* ?*measuredCurrent* ?*measuredVoltageDER*) crlf) ) But the Total Generation is showing 0. But I tried calculating in Java and it's showing a number. Can anyone please help me to solve this problem. Thank you.

    Read the article

  • Add a Carriage Return to the Output of an XSL Transformation

    - by dsrekab
    I am trying to use XSLT to convert an XML document to a text file and the text of the document looks fine. However, I need to add a carriage return after the end of each line (NOT A CRLF) and I seem to be failing in every attempt. I have tried adding just a CR at the end of the line like this: <xsl:text>&#xD;</xsl:text> I have tried changing my media-type to string, I have tried to add the disable-output-escaping attribute to the text element, but it always adds a CRLF. This is on a Windows OS and I know that Windows uses CRLF for a new line, but I would have thought you could override that if you said to specifically use only the CR or the LF (e.g. VB.net's VBCR or VBLF). Does anyone know if it is possible to only output a CR with XSLT? Thanks in advance.

    Read the article

  • xcodeproj merge fails when adding new group

    - by user1473113
    I'm currently using Xcode with Git, and I'm experiencing some troubles during the merge process of my xcodeproj. Developer1 create a new group in Xcode file arborescence the commit and push. Developer2 on an other computer do the same with an other group name, commit and pull(with merge). The xcodeproj of Developer 2 become unreadable with Xcode. But when I create a new file or just drag and drop files from finder to repository, the merge succeed. Did someone has experienced that kind of trouble? I'm using in .gitattributes: *.pbxproj -crlf -diff merge=union # Better to treat them as binary files. *.pbxuser -crlf -diff -merge *.xib -crlf -diff -merge and in my .gitignore # Mac OS X *.DS_Store *~ # Xcode *.mode1v3 *.mode2v3 *.perspectivev3 *.xcuserstate project.xcworkspace/ xcuserdata/ *.xcodeproj/* !*.xcodeproj/project.pbxproj !*.xcodeproj/*.pbxuser # Generated files *.o *.pyc *.hi #Python modules MANIFEST dist/ build/ # Backup files *~.nib \#*# .#*

    Read the article

1 2 3 4  | Next Page >