C :: Program Stalled At System Command?
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
ADVERTISEMENT
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
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
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
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
May 2, 2013
No I definitely used Visual Studio Command Prompt
c:Program FilesMicrosoft Visual Studio 9.0VC
un_process_from_service>make.bat
View 7 Replies
View Related
Feb 2, 2014
I know there has to be a system call to pause (not system("pause") execution of a program for a few seconds. I would like to give the illusion that my program is 'thinking' rather than just spit out the result as soon as the user has hit the enter key.
View 5 Replies
View Related
Sep 26, 2013
I am trying to fetch data from the USB device(say pendrive) connected to the USB port of a system. I have attached code.c file which I have wriiten for the same purpose, please find it. Here I am able to open the device file and read some random raw data which is in the log.txt file (also attached to this mail). But I want it to fetch data like minicom/teraterm does.
What methods and libraries I can use to do it successfully and how can it be done.
View 2 Replies
View Related
Apr 28, 2014
I need to program and simulate a 2 floor lift control system. How to do that ? I need to design its program only.
View 1 Replies
View Related
Nov 13, 2013
How difficult would it be to program a hash-map system where each "key" can have multiple values under indexes?
For example: "Word" -> 45(index 0) , 67(index 1) , 12(index 2). What could I start with to program this or where could I find a pre-made system that does this?
View 14 Replies
View Related
Jan 5, 2015
I have programmed a program for billing system. I have used parameters and arrays. All the functions are working except a one function. (Regular package function).
#include <iostream>
#include <fstream>
#include <string>
#include <ctime>
using namespace std;
void main(int &minutes, int &minutesd,int &minutesn) {
[Code] .....
View 3 Replies
View Related
Jan 10, 2014
How can I send information and receive from external command prompt from my program??. I want to run an external command prompt, a code that's is not mine, to send information to this command prompt, then make my program hit enter at the command prompt and then receive back information from the command prompt.
View 5 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>
#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
Jan 2, 2013
Why do i get this error?
View 4 Replies
View Related
Dec 8, 2012
I have two pieces of code:
Code:
#include <cmath>;
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <iomanip>
[Code] ....
I am using the gnu glpk library to calculate a linear program for my matrices. Why I get the error message exit code 3 which apparently means "The system cannot find the path specified"?
View 12 Replies
View Related