C :: Creating Shell In Linux

Feb 22, 2015

This is what so far i did

Code:
#include <stdio.h>#include <string.h>
#include <ctype.h>
#include <bsd/string.h>

int
main(void)

[Code] ....

How to do this Using the fork(), execvp() and waitpid() system calls, launches the requested program and waits until the program has finished.

View 3 Replies


ADVERTISEMENT

C :: How To Compile And Run Program From DOS Shell

Mar 19, 2013

How to compile and run program from DOS shell. Any list of procedures....

View 1 Replies View Related

C :: Call Another Program Via Shell Script

Oct 2, 2014

I'm trying to call another c program via shell script in c, but it just pop-up and close again.. here's my code:

char* command = "";
char temp[MAX_LENGTH] = "";

sprintf(temp, "gnome-terminal -e 'bash -c "./Isopropyl %s"'", editor -> filename);
command = malloc(strlen(temp) + 1);

if(command == NULL)
return;

strcpy(command, temp);
system(command);

View 1 Replies View Related

C/C++ :: Simple Shell Argument Parsing

Apr 9, 2014

Simple c shell I have been writing. The problem I am having is to do with my argument passing. I have written a simple state machine to parse commands given by the user into an appropriate array of character pointers for use with the function execvp().

My experience with c coding is limited, I think I'm getting confused with pointer manipulation and stack memory. I am trying to store the 'tokens' within my struct->argv[].

Add the ability to handle program names and parameters that contain white space: everything in between two double quote (") characters needs to be treated as one word! E.g. "./hello world" should be treated as the name of one program called hello world (in the current directory, with a space in the middle of the file name) rather than a program called hello with one parameter world.

Here is my parsing functionality.

struct Command {
char *name;
int argc;
char *argv[MAX_ARGS];
};
struct Command command;
void createToken(char *start, char *end)

[Code] .....

View 3 Replies View Related

C++ :: Sorting Data Saved Using Shell Algorithm

Feb 4, 2013

#include <iostream>
using namespace std;
class CD {
public:
static const int num = 100;
char publisher[num], title[num], location[num];

[Code] .....

View 1 Replies View Related

Visual C++ :: Shell (Namespace) Extension Not Registering?

Dec 13, 2012

I have created a Namespace Extension (I hope so) by creating a ATL Project with MFC support as dll in Visual Studio 2010.

Now I have a Implementation of IShellFolder:

Code:
// ILCShellFolder.h: Deklaration von CILCShellFolder
#pragma once
#include "resource.h" // Hauptsymbole
#include "NewNSE_i.h"
#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)

[Code] ....

Not any of those IShellFolder Methods is being called... When I attach the explorer.exe process (which I know I can use to debug on other projects, just in case to exclude errors) it tells me that the DLL is not loaded by the explorer.exe process.

View 1 Replies View Related

C++ :: Redirect Shell Standard Output Into Program Stream?

Oct 4, 2013

I want to take the standard output of a shell command (in Red Hat, using tcsh, in my case) and redirect it into my program for processing.

(Then ideally I would love to take the output of my program and redirect it to yet another command, but this is a second issue.) Simple example: I naively thought this might work:

I want to type this on the shell:

Code: $ echo Harry > hello and I was expecting this output on my terminal:
Code: $ hello, Harry And this would be my simple hello program:
Code: #include <iostream>
#include <string>
int main() {
std::string usrInput;
std::cin >> usrInput;
std::cout << "hello, " << usrInput << std::endl;
return 0;
}

View 3 Replies View Related

C++ :: Application To Load Other Applications In A Secure Shell Based On User Interaction

Jul 9, 2013

I will sketch the scenario I would like to get working below. I have one main application.

That application, based on user interactions, can load other applications in a secure shell. This means these child applications cannot interact with the OS anymore, nor with each other.

The parent program can at any time call functions of these child programs.

The child program can at any time call functions of these parent programs.

How to implement this in C++? Preferably both parent and child should be written in C++.

The performance of loading the child applications doesn't matter. The only thing that matters is the performance of the communication between child and parent.

View 4 Replies View Related

C :: Stop Shell From Automatically Converting Wildcards In Arguments To Directory Listings

Oct 2, 2014

Ok I'm on a Windows machine and I'm writing a simple tool to dump and touch ttf files. It's almost done except that the command line parser is giving nightmares. how do I stop the shell from automatically converting wildcards in arguments to directory listings? (I first flatten all arguments to a single string before parsing)

View 7 Replies View Related

C++ :: UDP Socket Library On Linux

Jan 29, 2014

I'm attempting to write a little UDP socket library in c++ on linux so a user can just create a new instance of a UDPSocket class, specify destination ip and port, and just connect. Then the user should be able to call send() or receive() in any order they want.. and here I encounter a little problem..

Most of the tutorials for udp socket sending out there include a bind() call when you create your "server" that is supposed to receive data, but the code that send data does not need one. Because I also want my library to support unicast/broadcast/multicast, I have read that I need to set the socket option SO_REUSEADDR on my sockets (since multiple sockets will need to be connected to same destination IP/port for broadcast/multicast)

My question is.. do I need to create 2 socket handles per "UDPSocke in order to make this work? One for sending and one for receiving data? In my code when I try to work with only 1 socket, it is only able to receive stuff from itself on unicast.. Or should I just remove the SO_REUSEADDR when in unicast mode, then try to bind with both sockets, accept that the bind will only work on the 1st socket, and take it from there?

View 1 Replies View Related

C :: Debugging A Code On Linux OS

Apr 11, 2013

I have a code that I'd like to debugg it.

Question
1 - What is the correct command line to use the debugger ?
2 - Do I need to install additional software for the debugger ?

if yes what it's name?

I use ububtu 12.4compiling command: gcc abc.c -lpthread -o abc

View 3 Replies View Related

C :: Implementing GUI On Linux Platform

Jul 6, 2014

I am an experience C programmer but never implement GUI.

I need to make a demo implementation that will be run on Linux and will implement GUI.

I searched the WEB and found lot of information, among is implementing the GUI in HTML and run the API through web browser.

How can I make such implementation in C?

View 2 Replies View Related

C :: Compiling 2 Files In Linux Gcc

Sep 22, 2014

I want to use two separate files in 1 program, but cannot get it to work. I don't know if it's my files or the compiling thats wrong. I have never used 2 files in my programs so far. Only used #include <stdio.h>.

Here are my files:
extern_static.c Code: extern int i;
int main(void)
{

[Code]....

View 10 Replies View Related

C :: File Which Can Be Compiled In Linux Via GCC

Aug 16, 2013

I have a c file which can be compiled in Linux via GCC , but when I compile it in NetBeans via Cygwin or MinGW , it doesn't work and keeps throwing a segmentation fault.

View 14 Replies View Related

C++ :: Works On Solaris But Not On Linux?

Apr 24, 2013

I have this following piece of code:

int id = 5;
const char *ptrId;
ptrId = ( int_to_str(id) ).getPtr(); // Works in Solaris well

But the above code prints some junk values when I run the same on Linux machine. But the following works well on Linux:

String temp = int_to_str(id);
ptrId = temp.getPtr();

The prototype of getPtr() is:
const char* String::getPtr() const

View 2 Replies View Related

C/C++ :: Linux Console Get Key State

Jan 23, 2014

I want to create command line game in Linux but I don't know to get the key state. I heard of getch() but that stops the program.

View 1 Replies View Related

C/C++ :: Opening Application From Another Linux Mac

Dec 15, 2014

I want to open an application A from another application B. By opening it, I don't want to open it within B. I found many ways to call an application from within another. However, what I want to do is open the other one(A) simultaneously. How can I achieve this? fork() and exec() seem to open A within B. I am developing a code for Linux and Mac.

View 7 Replies View Related

C++ :: Why Using Namespace Required In Linux But Not In Turbo

Jan 8, 2015

Why is using namespace needed in linux but not in turbo c++?

View 1 Replies View Related

C/C++ :: MD5 Checksum Mismatching On Windows And Linux?

Feb 17, 2014

I have implemented MD5 checksum algorithm by using C language, but it is resulting correct value in windows but not in Linux?

// Constants are the integer part of the sines of integers (in radians) * 2^32.
const uint32_t k[64] = {
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee ,
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501 ,
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be ,
0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821 ,

[Code] .....

View 2 Replies View Related

C++ :: Detect Arrow Key Press For Linux Only

May 13, 2012

I'm trying to implement this on ubuntu, to compile and run only under ubuntu.

I found 100s of other attempts at answering the general question of arrow key press in c++. Nothing solid.

Some recommend using the Readline for the functionality I am trying to implement, but I need to stay clear of GNU licences if I can for this project. And some tips only work on projects for windows machines... for example the conio library.

For linux there may be the option of using the ncurses library which I will take a look at, but I am stubborn and want to implement this myself. It should be an easy straight forward thing to do, which is why I am a bit frustrated at the moment.

Here is my test code so far.

#include <iostream>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
using namespace std;
int main(void) {
char a;
stringstream ss;
string s;

[Code] ....

So! This works... 80% of the problem is solved. If you compile this, g++ under linux, ubuntu in my case, and run. Each keystroke reveals the correct key numbers.

q=113
w=119

when I click on the up key I get,

up = 279165

I thought, I can use this number is a if(int == '279165') to detect the up key.

I was not so lucky... this int is not behaving like an int!

So I modified the code to see it I could carry out an int operation on this number.

I added a 100000 to int i.

cout<< i + 100000;

Code:
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
using namespace std;
int main(void) {
char a;
stringstream ss;
string s;

[Code] .....

Compiling and running this, and pressing the UP key gives the following number.

100027100091100065

Some some sort of array, something like, [27][91][65].

I tried all ways to access these individual numbers, actually the third one for comparison purposes, but no luck.

For completeness sake I list the other arrows.

UP = [27][91][65]
DOWN = [27][91][66]
LEFT = [27][91][68]
RIGHT = [27][91][67]

A little further digging shows that these numbers are derived from the representation of a "multi-char" constant, the data type given when pressing special characters...

Now here is the main problem I have, I can find ANY decent documentation on how to handle and play with "multi-char" .

View 4 Replies View Related

C :: Build A Linux Process Scheduler From Scratch

Apr 5, 2013

I'm trying to build a Linux Process Scheduler from scratch but dont know where to start.

View 1 Replies View Related

C :: Linux IPC Implement Signal And Slot For New Message

Dec 4, 2014

I'm new in IPC. I would like to implement a signal of a new message, which calls the slot function, eg .:

Code:
msg_on_newMessange(type, &slotFunction);

My code:
Header file: messages.h
Parent file: parent.c
Child file: child.c

How can I do this ?

View 2 Replies View Related

C :: Program That Lets To Download Torrents On Linux

Mar 22, 2013

I want to create a program that lets you download torrents on linux ... how to start ...

View 1 Replies View Related

C++ :: Detecting Any Key Of Keyboard And Mouse On Windows / Linux?

Jun 20, 2014

I am trying to detect keys pressed on a keyboard and mouse on both, Windows and Linux but I am unsure what would be the best practice way to do so. Will I have to detect the keys for each platform individually? Would you make use of an event listener? What's the best way to detect the input-devices?

View 1 Replies View Related

C++ :: Create Keylogger For Windows And Linux Using Same Function?

Nov 2, 2013

is there a way to create a keylogger for windows and Linux using the same function. Any function to do it on linux and how to use it.

View 3 Replies View Related

C++ :: Getting Consistent Type Names Under Windows And Linux?

Dec 4, 2014

I'm writing a server/client application in C++, one linux and one windows. The generic communication method is to use the boost::serialization package, but I'll also use a header to distinguish the type of the serialized string.

Here is the struct that the two programs communicate with

struct SerializeString {
std::string type_name;
std::string serialized_string;
friend class boost::serialization::access;
template<typename Archive>
void serialize(Archive& ar, const unsigned version) {
ar & type_name & serialized_string;
}
};

When one side wants to pass an object to another side, it uses typeid(T).name() for the field type_name. The receiving side receives SerializeString and checks its type_name against various acceptable structs as follows:

if (ss.type_name == typeid(XXX).name()) {
// deserialize ss.serialized_string to XXX and do something with it
} else if (ss.type_name == typeid(YYY).name()) {
// deserialize ss.serialized_string to YYY and do something with it
} else if (ss.type_name == typeid(ZZZ).name()) {
// deserialize ss.serialized_string to ZZZ and do something with it
} else {
// etc...
}

This worked fine when I was using Windows VS2013 on two different windows platform. However when I switch one to Linux there is a problem because their typeid(XXX).name() returns different things. So question here, is there a generic way to get some sort of unique names across platform / compiler? Or is my method reasonable at all?

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved