C :: Gzip System Linux - Program To Unite 2 Commands Into 1 Command
Sep 15, 2013
I'm writing a program to turn the two commands "gunzip file.tar.gz" then "tar -xvf file.tar" into "x file.tar.gz", but I've ran into a problem I can't find a solution to, here are the outputs I get depending on if I use a gunzip -f flag in my system() call or not:
if I use: (void)system("gunzip ", store );
> x file.tar.gz
gzip: compressed data not read from a terminal. Use -f to force decompression.
type: gzip -h
store 1: file.tar.gz
tar: option requires an argument -- 'f'
[code]....
I don't know if the problem is something to do with my code or something to do with gunzip and if it is to do with gunzip if I can even solve it with my code? I've tried for a while to find more info and read the gunzip man file, ran "gunzip file.tar.gz" outside of my program and found that it works normally producing file.tar so I suspect the problem is related to system()?
View 3 Replies
ADVERTISEMENT
Oct 28, 2014
I have code that creates an index file created from a data file of records.
#include <iostream>
#include <fstream>
#include <map>
#include <sstream>
#include <string>
#include <iomanip>
using namespace std;
class Record {
[Code]...
I now need to write a second program that allows the user to enter a command on the Linux command line such as
search 12382 prog5.idx
and returns the information for the record with that key. The code I included for the index file is correct and works properly, but how to write the second program.
Here is the index file created by the first program:
8: blank 0 $ 0.00
12165: Item16 30 $ 7.69
12345: Item06 45 $ 14.20
12382: Item09 62 $ 41.37
12434: Item04 21 $ 17.30
16541: Item12 21 $ 9.99
21212: Itme31 19 $ 8.35
34186: Item25 18 $ 17.75
41742: Item14 55 $ 12.36
The top line is a dummy record, the first number is the size of the file.
View 19 Replies
View Related
Dec 11, 2013
I have written a program which uses a pid to check if the process is currently running and return a value based on the system call result.But the program core dumps
Code:
#include <stdio.h>
#include <string.h
int main( argc, argv )
int argc;
char * argv[];
{
int p_pid = 99;
char buff[1000];
}
[code]....
What is the mistake in this code and is it portable in both unix/linux , is the method secure (grepping for program name )?
View 6 Replies
View Related
Dec 22, 2014
I am trying to recreate this bash command in c code:
Code: bash-4.2$ exec 3<<<teststring
bash-4.2$ cat <&3
teststring
bash-4.2$
I've written a small program to do this as shown below:
Code: bash-4.2$ cat test.c
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
[Code].....
View 3 Replies
View Related
Sep 17, 2014
how to invoke a UNIX command within a program
I found this:
dd if=/dev/urandom of=myrandom bs=100 count=1
and I found this:
dd if=/dev/zero of=mytestfile.out bs=1 count=0 seek=1G
I want to call this command, by using the command line and typing Generate or something to that effect.
Basically, I want to be able to build random size files, content isn't important to me at this time.
View 8 Replies
View Related
Nov 7, 2013
So, as far as I can tell, this code should run a system command from the C++ program:
system("ping 192.168.1.2 /t /l 32768");
However, I just keep getting a "system Was not declared in this scope" error message. Is there something wrong with this?
View 1 Replies
View Related
Sep 18, 2012
In Windows, if you open a command prompt, there are a bunch of keywords like, 'chdir', 'copy', ...
What I'm trying to figure out is how to use that COPY command in c++ code. I want to use the COPY command with the options (/a, /b, ...).
View 3 Replies
View Related
Oct 28, 2014
I have code that creates an index file created from a data file of records.
#include <iostream>
#include <fstream>
#include <map>
[Code]......
View 3 Replies
View Related
Feb 7, 2013
I want to run Unhidden.exe in drive N: and send char to that program. I use function like this
Code:
system("N:/Unhidden.exe");
It can open Unhidden.exe but it run in visual studio 2010Projects . I try to use command N: and Unhidden.exe in cmd it can run in drive N: . So I try to use function like this
system("N:");
system("Unhidden.exe");
but it not found Unhidden.exe . How to use 2 command in sytem() function ?
View 4 Replies
View Related
Aug 1, 2013
I've read that we can write a program that displays a menu of commands for the user to choose from.We can write some functions that implement these commands, then store pointers to the functions in the array :
Code:
void ( *file_cmd[])(void) = { new_cmd , open_cmd }; // 2 cmd's for simplicity
We can get a similar effect with a switch statement but using an array of function pointers gives us more flexibility since the elements of the array can be changed as the programm is running.
I decided to write an example about this in order to understand better the context, I am facing some problems though :
Code:
#include<stdio.h>
#include<stdlib.h>
typedef void (*p_foo) (int);
void foo(int x);
void foo2(int y);
[Code] .....
The problems are :
Code:
TEST2.c:9: warning: initialization from incompatible pointer type
TEST2.c:9: warning: initialization from incompatible pointer type
TEST2.c:25: error: too few arguments to function "*(arr + (long unsigned int)((long unsigned int)i * 8ul))"
View 14 Replies
View Related
Apr 19, 2014
I was interested in making a food ordering program utilizing voice commands. I hope to build a GUI with items listed on one side, and with voice commands picking up on key words that will add the food to the right of what you chose.
View 4 Replies
View Related
Sep 26, 2014
#include<iostream>;
using namespace std;
int strlen(char []);
void strcat(char S1[], char S2[], int size_1, int size_2);
const int SIZE = 100;
const int MAX = 100;
[Code]...
i have been trying to do a function that unites strings entered by user, i need to do this without any other libraries but i keep getting an output of the first word and dots.
View 5 Replies
View Related
Oct 4, 2012
Can I extend the header of a file compressed by gzip? I mean I can insert more information to the start of header file, can't I?
View 3 Replies
View Related
Mar 22, 2013
I want to create a program that lets you download torrents on linux ... how to start ...
View 1 Replies
View Related
Mar 6, 2015
I need to write a c program that can receive signals and recognize a certain pattern (SIGUSR1, SIGUSR2, SIGUSR1, SIGUSR2). once the pattern is caught the program terminates itself.
I am able to send the signals to the program from a different process, but I am unsure on how to get the signal handler to recognize the pattern. here is what i have so far:
Code:
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
sig_atomic_t sigusr1_count = 0;
sig_atomic_t sigusr2_count = 0;
[Code] .....
I just need getting the program to be able to catch that specific pattern.
View 4 Replies
View Related
Dec 2, 2013
I'd like to add a 'command' to my C program. For example if someone types 'get out' it closes the shell and quits. I want the 'get out' command to work like 'exit'. How do I write a code like this
Code:
char entry[15];
scanf("%[^
]", &entry);
if (entry = "get out")
do "exit";
View 14 Replies
View Related
Mar 27, 2014
I am working on a project that is like a banking system and needs to include making a withdrawal, transaction, deposit, query, and transaction.
Code:
#include <stdio.h>
//#define true
//#define false
//assume there is money in the account. $10,000
void deposit(){
[Code] ....
View 1 Replies
View Related
Mar 1, 2013
I just started my task with Ordering system. what should I use if I'm going to ask the user if he wants to exit the system, he will press(zero)0 to exit the program and press Y(uppercase or lowercase) to continue?
View 1 Replies
View Related
Apr 17, 2013
So I know that I can call a program by system("prog.exe"), but what do I add in when I want to pass a parameter?
View 2 Replies
View Related
Jul 28, 2014
I'm currently making something with C++ for a computer at my house. I have a program in which I let run minimized and hidden on my home computer which will save any application that is opened. It will log it so I know if my kids are on my office computer (they shouldn't be.).
I'm curious as to if I can make the program linked to a program I make on my work computer (at my workplace) and execute a command. I'm interested in making it so I can always be connected from the Workplace app to the Home Office App.
My idea for the program is to have a sort of administrative way of shutting the computer down or locking it remotely. If I see they are using the PC in my office, I want to be able to simply type a phrase and shut the computer off or lock them out.
View 1 Replies
View Related
Nov 22, 2013
I am looking to make a program for C++ that has a GUI other than command prompt. The program I am trying to create will ask certain questions and display the results at the end after all questions are asked and have 2 copies of the results one over the other that can be printed as a receipt. Basically I am wondering can I do this using C++. Also I want another GUI other than command prompt as well. Something close to what windows uses if possible.
View 5 Replies
View Related
Feb 15, 2013
I am facing a problem in C++,I want to execute a command in Command prompt from a specific path.I am able o select a path and execute cmd.exe using the function ShellExecute but the problem is after selecting the path I am not able to execute the command, the command is appearing on another command prompt.
View 4 Replies
View Related
May 26, 2014
In the following program, I have gotten it to work with IO redirection (not shown in this particular code), and have made some minor adjustments to get it to work with file processing. The only thing I have to do now is get it to work with command line arguments, and am slightly lost (and I have looked into it).
I basically just need to take a text file from a certain directory and send it to my program. Would need two files, an input and output file.
main.c
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "LAB_6B_7B.h"
[Code].....
View 8 Replies
View Related
Sep 22, 2014
I have written a C++ program that is supposed to open two text files (prog2a.dat and prog2b.dat) and write the contents of a specified range of lines to an output file (outfile.dat). I wrote a program that based on the example we were given (to take lines 5-15 from the first file and lines 4-12 of the second file and merge them into the output file) works perfectly. However, after asking my professor for some clarification on another part of the assignment, I found out I have not done this correctly. I have the code written so that it will always output the range of lines I mentioned earlier, but the program is actually supposed to allow the user to merge the files from the command line using whatever range they want by typing in the following command:
prog2 in1 5-15 in2 4-12 outfile
But I'm not sure how to tweak my current program to allow this to be done.
Here is the code that I have written, keep in mind that this works properly for the way it is written, but not how it is supposed to work for the purposes of the command line (hopefully that makes sense):
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
int main() {
// Create output file
std::ofstream outFile("outfile.dat", ios::out);
[Code] .....
Is there any simple way to make this work as I described using the command line? Also, I am supposed to break this up into three files, a header file, the program file, and a test file (the test file contains main() and should close the 3 open files and display any error messages), but I'm getting really confused as to what should go in the header file. I know the header file should contain class definitions and constructors, but don't really know how to make that work for this specific program?
View 13 Replies
View Related
Aug 13, 2012
i wrote the c program for command line arguments,but i don't know how execute c program through command prompt
i did like this
d: cin>
then how should i proceed for execution
View 1 Replies
View Related
Mar 10, 2014
The below program is supposed to display the contents of all files listed in the command line. When I try to run the program I get the fatal error "Debug Assertion Failed" Expression: file != NULL. I've done some researching on the matter and I gather it might be because I don't have any files listed in the command line?
How to enter files in the command line! I opened the Command Window in Windows XP and tried typing in "C> argc" and "% argc" (argc being the name of the file containing the below program) without any luck.
Code:
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char * argv[]) {
int ch; // int to hold EOF
int count;
FILE *fp;
for(count = 1; count <= argc; count++) // agrc loop
[Code]...
View 5 Replies
View Related