Sponsored Content
Top Forums UNIX for Dummies Questions & Answers encountered a command line argument to c program puzzle! Post 302564787 by hackmanbsg on Friday 14th of October 2011 03:24:53 PM
Old 10-14-2011
encountered a command line argument to c program puzzle!

Hi,
I hope this is the right place to post this:
I have a cprogram written in openCV which reads a video file and does some processing: Here's a relevant code snippet:
Code:
//just in case you needed to know what libraries I included
#include<iostream>
#include<opencv/cv.h>
#include<opencv/highgui.h>
#include<dirent.h>
#include<string>
#include<cstdlib>
#include<cstdio>
#define SPACE_BAR 32
#define ENTER_KEY 10

using namespace std;
int main(int argc,char *argv[]){
        char title[]="ImageClipper";
        char title2[]="Cropped Image";
        if(argc!=2 && (cout<<"Usage: ./imageclipper <avi-path>"<<endl))exit(0);

        char *avifile=argv[1];
        cout<<"avi file is "<<avifile<<endl;

        CvCapture *capture=NULL;
 CvCapture *capture=NULL;
        capture=cvCreateFileCapture(avifile);
        if(capture==NULL){
          cout<<"capture is Null..exiting"<<endl;
          exit(1);
        }

// code to open some windows providing an interface to select sub regions of a frame...but the above lines should be sufficient
...
}

The problem faced:
When I run

Code:
./a.out path/to/video.avi

It works perfectly.

but when I run the following in a shell script(after creation of the txt file offline):
Code:
find path_to_folder_containing_avis -name "*.avi" > to_process.txt

for f in `cat to_process.txt`
do
./a.out $f
done

I get my error message "Capture is Null..exiting"(after the c++ program printed the right name). Any ideas why it's getting messed up?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

command line argument parsing

how to parse the command line argument to look for '@' sign and the following with '.'. In my shell script one of the argument passed is email address. I want to parse this email address to look for correct format. rmjoe123@hotmail.com has '@' sign and followed by a '.' to be more... (1 Reply)
Discussion started by: rmjoe
1 Replies

2. Shell Programming and Scripting

passing a command line argument

I have a shell script which does the encryption of a file where i am passing the file name as a command line argument,but later on the script waits on the screen to enter Y or N what is the command i should be using on the shell script #!/bin/bash -x outfilename=file.out echo... (8 Replies)
Discussion started by: rudoraj
8 Replies

3. Shell Programming and Scripting

How to get the value in last command line argument???

Say I want to get the value of last command line argument using the value in $# (or some other way if u can suggest) how do I do it?? $"$#" `$"$#"` These don't work :( (4 Replies)
Discussion started by: amit_oddey21
4 Replies

4. Shell Programming and Scripting

assign a command line argument and a unix command to awk variables

Hi , I have a piece of code ...wherein I need to assign the following ... 1) A command line argument to a variable e.g origCount=ARGV 2) A unix command to a variable e.g result=`wc -l testFile.txt` in my awk shell script When I do this : print "origCount" origCount --> I get the... (0 Replies)
Discussion started by: sweta_doshi
0 Replies

5. Programming

Command Line Argument

Hi, I have a very simple C program which will run in UNIX. When i am passing * as the command line argument, i am gettig the below output. Program: #include <stdio.h> #include "mylibrary.h" int **environ; int main(int argc,char *argv) { int i; printf("\nHello... (2 Replies)
Discussion started by: dsudipta
2 Replies

6. Shell Programming and Scripting

Need Help with the argument passing Through Command line

$$$$$ (5 Replies)
Discussion started by: asirohi
5 Replies

7. Shell Programming and Scripting

command-line line 0: Missing yes/no argument

Hi Guys When I run the below command ssh -o 'PasswordAuthentication yes' -o 'PreferredAuthentications publickey' -i $HOME/.ssh/id_dsa Server_Name I found the below error ommand-line line 0: Missing yes/no argument Kindly help me to sort out Double post, continued... (0 Replies)
Discussion started by: Pratik4891
0 Replies

8. Shell Programming and Scripting

Can a string be a command line argument?

I would like to use a string as a command line argument...is this possible using TCSH? For example say my script is called TEST and I would like to pass a string into my script stating why the test failed. EXAMPLE: TEST "Failed due to missing statement" (4 Replies)
Discussion started by: thibodc
4 Replies

9. Shell Programming and Scripting

Specify an entire UNIX command as a command line argument

I'm trying to write a bash script called YN that looks like the following YN "Specify a question" "doThis" "doThat" where "doThis" will be executed if the answer is "y", otherwise "doThat". For example YN "Do you want to list the file dog?" "ls -al dog" "" Here's my attempt... (3 Replies)
Discussion started by: LeoKSimon
3 Replies

10. UNIX for Beginners Questions & Answers

Command line argument

Hi Guys, I'm trying to work out how to add a command line argument inside single quotes. Would anyone be able to help please as I'm going mad :) I want to be able to place the filename on command line and it then be used in a script but it needs to have quotes surrounding it. Thanks in... (4 Replies)
Discussion started by: mutley2202
4 Replies
TREE-PUZZLE(1)						      General Commands Manual						    TREE-PUZZLE(1)

NAME
tree-puzzle - Reconstruction of phylogenetic trees by maximum likelihood SYNOPSIS
tree-puzzle DESCRIPTION
This manual page documents briefly the tree-puzzle command. This manual page was written for the Debian GNU/Linux distribution because the original program does not have a manual page. TREE-PUZZLE is the new name for the program previously known as PUZZLE! tree-puzzle is an interactive console program that implements a fast tree search algorithm, quartet puzzling, that allows analysis of large data sets and automatically assigns estimations of support to each internal branch. TREE-PUZZLE also computes pairwise maximum likelihood distances as well as branch lengths for user specified trees. Branch lengths can also be calculated under the clock-assumption. In addi- tion, TREE-PUZZLE offers a novel method, likelihood mapping, to investigate the support of a hypothesized internal branch without computing an overall tree and to visualize the phylogenetic content of a sequence alignment. There is also a paralellized version tree-ppuzzle available. OPTIONS
There are no options. For usage please look at /usr/share/doc/tree-puzzle/tree-puzzle.pdf. SEE ALSO
phylip(1), treetool(1). tree-ppuzzle(1). This manual page was written by Dr. Guenter Bechly <gbechly@debian.org>, for the Debian GNU/Linux system (but may be used by others). April 20, 2001 TREE-PUZZLE(1)
All times are GMT -4. The time now is 08:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy