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 8312527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:11:41+00:00 2026-06-08T20:11:41+00:00

Rank beginner here please be gentle… I’m writing a program in perl that finds

  • 0

Rank beginner here please be gentle…
I’m writing a program in perl that finds all of a certain file type and calls and another program called newstack to convert the file types.

When I run newstack oldfileame newfilename from my shell it works fine.

when my program runs system("newstack oldfileame newfilename") newstack returns the error:

ERROR: NEWSTACK - NO INPUT FILE SELECTED
sh: line1: ./oldfilename: cannot execute binary file

If I write a shell script that does the same thing, running newstack on the files one at a time it works fine. Is there something I’m missing here why it fails when run within the context of the perl program?

Newstack is from the IMOD suite of programs, I don’t know what it’s written in. The files are mrc files which are binary image files.

EDIT:: Here’s the actual code as requested:

print "Enter the rootname of the files to be converted: ";
my $filename = <STDIN>;
chop $filename;

my @files = qx(ls $filename*.mrc);     
open LOGFILE, (">modeconvert-log");     
foreach my $mrc (@files)           
{        
print LOGFILE "$mrc";       
system("newstack -mode 2 $mrc $mrc");     
} 
my $fileno = @files;
print "$fileno files converted\n";

I added chop $mrc after line 8 and it fixed the problem

  • 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-06-08T20:11:44+00:00Added an answer on June 8, 2026 at 8:11 pm

    The code you posted and the code you executed differ. In the code you executed, there was a newline after newstack

    $ perl -e'system("who\n oldfileame newfilename")'
    sh: line 1: oldfileame: command not found
    

    Remove the newline using chomp($x) or using $x =~ s/\s+\z//;.


    my @files = qx(ls $filename*.mrc);
    

    should be

    my @files = qx(ls $filename*.mrc);
    chomp @files;
    

    Or better yet:

    my @files = glob("\Q$filename\E*.mrc");
    

    The above and other fixes:

    use IPC::System::Simple qw( system );                          # Replaces system with one that dies on Checks for errors.
    
    open(my $LOGFILE, '>', 'modeconvert-log')                      # Avoids global vars.
       or die("Can't create log file \"modeconvert-log\": $!\n");  # Adds useful error checking.
    
    print "Enter the rootname of the files to be converted: ";
    my $filename = <STDIN>;
    chomp $filename;                                               # chomp is safer.
    
    my @files = glob("\Q$filename\E*.mrc");                        # Works with file names with spaces, etc.
    
    for my $mrc (@files) {
       print $LOGFILE "$mrc\n";                                    # Was missing a newline.
       system("newstack", "-mode", "2", $mrc, $mrc);               # Works with file names with spaces, etc.
    } 
    
    print 0+@files, " files converted.\n";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an MPI program in which rank 0 reads parameters from a
Could people please rank some programming languages like C,C++,Java,perl etc on benchmark line of
I am a rank beginner in C#. I am currently using this code: objGraphics.Clear(SystemColors.Control);
I have a query that creates a result set like this: Rank Name 1
Is there an algorithm that allows to rank items based on the difference of
I'm a rank beginner with WPF and I don't even know where to look
Here is the original image: http://rank.my/public/images/uploaded/orig-4193395691714613396.png And here it is scaled down to 300x225:
My observation is that google doesn't rank dot.tk domain names as highly as other
On SO 18 Joel mentioned an algorithm that would rank items based on their
I've seen several products that will track the sales rank of an item on

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.