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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:30:36+00:00 2026-06-12T09:30:36+00:00

I understand this is usually to do with recursion, except I am pretty sure

  • 0

I understand this is usually to do with recursion, except I am pretty sure I am not doing this.
On each time round the loop it gives a segmentation error pointing to the for loop’s line.

for file in $DATAFOLDER*; do
    echo $file;
    filename=$(basename $file);
    echo $filename;
    echo "$DESTFOLDER$SUBFOLDER${filename%%.*}"
    pwd
    # move data to cppapplication folder
    cp -R "$file" "$DESTFOLDER";
    sleep 1
    # create subdirectory
    mkdir "$SUBFOLDER";
    # create new folder for extracted data
    mkdir "$DESTFOLDER$SUBFOLDER${filename%%.*}";
    # copy MassLynx header file into new folder (get the description info)
    cp "$file/_HEADER.TXT" "$DESTFOLDER$SUBFOLDER${filename%%.*}";
    # run the cppapplication
    # <program> <project file> <MassSpectrum> <Mobilogram> <bins in Da> <extract m/z ranges>
    ./cppapplication.exe "$filename" 0 1 1 0 ;
    # fix last character comma bug
    sed -i '$ s/,$//g' MassMobility.txt
    # move the created files into the new folder
    mv Mobilogram.txt "$DESTFOLDER$SUBFOLDER${filename%%.*}";
    mv MassMobility.txt "$DESTFOLDER$SUBFOLDER${filename%%.*}"; 
    mv MassMobilityXaxis.txt "$DESTFOLDER$SUBFOLDER${filename%%.*}";
    mv MassMobilityYaxis.txt "$DESTFOLDER$SUBFOLDER${filename%%.*}";    
    # get driftscope quicklook image
    sleep 3
    python "C:\Users\ganesh\Dropbox\PhD\03_Amphitrite\CppApplication\quicklook_driftscope.py" "$DESTFOLDERWINDOWS$SUBFOLDERWINDOWS" "${filename%%.*}" "$DESTFOLDERWINDOWS$SUBFOLDERWINDOWS${filename%%.*}";


    # remove MassLynx Project
    rm -r "$filename";

done

Aside from the copying of the file, I don’t think the loop has any contact with the original folder being looped through.

This is the error:

./extract_all_projects.sh: line 26:  7500 Segmentation fault      (core dumped) 

I have no idea what the problem is as “cppapplication.exe” works fine on these files if run outside of the bash script.

  • 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-12T09:30:37+00:00Added an answer on June 12, 2026 at 9:30 am

    Your $filename could be empty or not as expected. I’m sure the segfault is the cppapplication.exe crashing (Why didn’t you tell us what line 26 is?) To test this, try

    ./cppapplication.exe "" 0 1 1 0
    

    and see if it segfaults. If I had to guess: the app tries to open a file but doesn’t check the return value and soldiers on with a NULL pointer.

    BTW, all except the first semicolon in your script are useless. The shell is not C 🙂

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

Sidebar

Related Questions

I understand this is not according to standard, however a partner is passing XML
Note: I understand this is not strictly about development, but in the earlier threads
I usually understand recursions pretty well, but because I'm new to C functions like
From what i understand, This usually has to be done server side. However i
I was reading this link http://dec.bournemouth.ac.uk/staff/awatson/micro/articles/9907feat2.htm I could not understand this following statements from
I don't understand this issue. Because this usually worked till now. This method is
I usually do not have difficulty to read JavaScript code but for this one
I understand this is an easy question but for some reason this just isn't
I understand this is a subjective question but I want to see how others
I understand this code calculates the sum of the args of a variable, however,

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.