Segmentation Fault in BASH


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Segmentation Fault in BASH
# 1  
Old 03-15-2013
Segmentation Fault in BASH

So I am writing a script that will interpret the partition table of a forensic evidence file, find the unallocated spaces, then determine if those spaces are empty or contain data.

I am stuck on the first command. *facepalm*

The command is mmls. When I run mmls <image> in BASH, no problem. When I run mmls in the script (even with nothing else), I get a segmentation fault (with a 4k or 5k number). This occurs whether I use $1 or $image as an argument for mmls.

Any help would be appreciated.
# 2  
Old 03-15-2013
Without seeing your script, nobody here can really help you.

I would point out that TSK tools such as mmls are typically meant to be used interactively and not within a script.
# 3  
Old 03-15-2013
I would also point out that it's not BASH that's segfaulting.
# 4  
Old 03-15-2013
Quote:
Originally Posted by fpmurphy
Without seeing your script, nobody here can really help you.

I would point out that TSK tools such as mmls are typically meant to be used interactively and not within a script.
Apologies

Code:
#!/bin/bash -xv
image=$1
mmls $image

# 5  
Old 03-16-2013
What if you just put the one line "mmls image_to_use" in the shell script (even leave out #! line). In other words, try the simplest case, see if that works, add in other details, find out the mistake.
# 6  
Old 03-16-2013
Thanks for all the feedback everyone.

I got the answer from the Sleuthkit users list.

I needed to have "$image" in quotes. It turns out that when I used \ to escape the white space, the parent process chewed through that leaving the space unescaped by the time it was passed to the child process. Hope that makes sense.
# 7  
Old 03-16-2013
Makes perfect sense.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

C. To segmentation fault or not to segmentation fault, that is the question.

Oddities with gcc, 2.95.3 for the AMIGA and 4.2.1 for MY current OSX 10.14.1... I am creating a basic calculator for the AMIGA ADE *NIX emulator in C as it does not have one. Below are two very condensed snippets of which I have added the results inside the each code section. IMPORTANT!... (11 Replies)
Discussion started by: wisecracker
11 Replies

2. Homework & Coursework Questions

Segmentation Fault

this is a network programming code to run a rock paper scissors in a client and server. I completed it and it was working without any error. After I added the findWinner function to the server code it starts giving me segmentation fault. -the segmentation fault is fixed Current problem -Also... (3 Replies)
Discussion started by: femchi
3 Replies

3. Programming

Using gdb, ignore beginning segmentation fault until reproduce environment segmentation fault

I use a binary name (ie polo) it gets some parameter , so for debugging normally i do this : i wrote script for watchdog my app (polo) and check every second if it's not running then start it , the problem is , if my app , remain in state of segmentation fault for a while (ie 15 ... (6 Replies)
Discussion started by: pooyair
6 Replies

4. UNIX for Dummies Questions & Answers

Segmentation fault

#include<stdio.h> #include<malloc.h> #include<unistd.h> #include<stdlib.h> void *start_1(void *argv) { printf("thread 0x%x\n",(unsigned int)pthread_self()); pthread_exit((void*)1); } void *start_2(void *argv) { printf("thread 0x%x\n",(unsigned int)pthread_self()); return (void*)2; }... (2 Replies)
Discussion started by: vincent__tse
2 Replies

5. Programming

segmentation fault.

This code is causing a segmentation fault and I can't figure out why. I'm new to UNIX and I need to learn how to avoid this segmentation fault thing. Thank you so much. Thanks also for the great answers to my last post.:):b: int main() { mysqlpp::Connection conn(false); if... (3 Replies)
Discussion started by: sepoto
3 Replies

6. Programming

Segmentation fault.

I'm getting a segmentation fault. I'm new to Linux programming. Thanks so much for all of your input.:eek: #include </usr/include/mysql++/mysql++.h> #include <stdio.h> #include <iostream> #include <sstream> #include <string.h> using namespace std; int outputToImport(const char*... (1 Reply)
Discussion started by: sepoto
1 Replies

7. Programming

segmentation fault

What is segmentation fault(core dumped) (1 Reply)
Discussion started by: gokult
1 Replies

8. Programming

Why not a segmentation fault??

Hi, Why I don't receive a segmentation fault in the following sample. int main(void) { char buff; sprintf(buff,"Hello world"); printf("%s\n",buff); } If I define a buffer of 10 elements and I'm trying to put inside it twelve elements, Should I receive a sigsev... (22 Replies)
Discussion started by: lagigliaivan
22 Replies

9. Linux

Segmentation fault

Hi, on a linux Red HAT(with Oracle DB 9.2.0.7) I have following error : RMAN> delete obsolete; RMAN retention policy will be applied to the command RMAN retention policy is set to redundancy 2 using channel ORA_DISK_1 Segmentation fault What does it mean ? And the solution ? Many thanks. (0 Replies)
Discussion started by: big123456
0 Replies

10. Programming

segmentation fault

sometimes for this code i get a segmentation fault for codes llike this : int main{ int * a= 0; int b; a = (int*)malloc(sizeof(int)); ///some code using these variable but no freeing of a if(a){ free(a); a = 0; } return... (3 Replies)
Discussion started by: wojtyla
3 Replies
Login or Register to Ask a Question