Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6235411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:39:51+00:00 2026-05-24T10:39:51+00:00

After i changed: system(recode ISO-8859-1..UTF-8 $csvPath); if($? == -1) { die( failed\n); } to:

  • 0

After i changed:

system("recode ISO-8859-1..UTF-8 $csvPath");
if($? == -1) {
    die(" failed\n");
}

to:

if(system("recode ISO-8859-1..UTF-8 $csvPath")) {
        die(" failed!");
}

it works better but still not always.

Code snippet:

print("recoding file to utf-8...");
#`recode ISO-8859-1..UTF-8 $csvPath`;
system("recode ISO-8859-1..UTF-8 $csvPath");
if($? == -1) {
   die(" failed\n");
}
print(" done!\n");

This doesn’t happen all the times. Sometimes it works sometimes not.

If it doesn’t works (script doesn’t finish in that case) the first print works, but the the second one with “done!” is never printed even if it the external command worked.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T10:39:51+00:00Added an answer on May 24, 2026 at 10:39 am

    Your test if($? == -1) doesn’t make much sense. $? will be 0 if the command succeeded, non-0 if it failed. For example, if the command did an exit(1), $? should be 256 — at least on Unix-like systems. And it’s probably cleaner to test the value returned by system() rather than examining $@ after the fact.

    Try setting $| = 1; at the top of your program; this makes your output unbuffered, and might let you see some output your script is producing before it dies.

    Print the exact value of the command string before executing it. If $cvsPath is an empty string (or if it’s undef and you haven’t enabled warnings), then you’re invoking recode with no file argument, and it will read from standard input. That might explain the behavior you’re seeing.

    Though this isn’t directly relevant to your problem, if system() is given a single argument, and if that argument contains shell metacharacters (including blanks), then the command is executed by the shell. With multiple arguments, it invokes the command directly:

    system('recode', 'ISO-8859-1..UTF-8', $csvPath);
    

    perldoc -f system for more information.

    And in fact, if a bad value of $cvsPath is the cause of your problem, that could have revealed it, since it would pass an empty string as a separate argument to recode. The error message recode produces in that case is:

    recode: fopen (): No such file or directory
    

    (the empty file name is shown between the parentheses).

    Note that a lot of this is guesswork based on incomplete information. Posting a small complete program that exhibits the problem would make this a lot easier.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following script works fine: $(#regform).validate().showErrors({username:message}); After I changed the script to the below
I have a segmentation fault in the code below, but after I changed it
My web app runs fine after I changed the system locale however whenever files
I have a listview which has its datasource changed after update of a search
I have a large PHP application. After I changed some settings I get a
A strange thing happened after a supplier changed the XML header a bit. I
I changed my .autotest file to use it with a Ruby-based project. After that,
VS2008 shuts down right after converting any VS2005 solution. The solution icon is changed
Our embedded system is built on a hw/sw platform made by enea. After the
Apple has recently changed the portal. Some of the changes are aery good, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.