Programming :: CreateProcess() In C \ Specify The Location Of The File As An Argument?

Aug 31, 2010

am coding a chat program in C (win32), where I need both the client and the server to communicate, without waiting for a reply from the other side, like the way we chat in any messenger. Is there any way of accomplishing it? I tried out CreateProcess() function, but am not clear how to specify the location of the file as an argument.If there are better techniques than CreateProcess(), then

View 13 Replies


ADVERTISEMENT

Programming :: C - User To Input The Name Of A File As An Argument

Aug 5, 2010

Write a program that requires the user to input the name of a file as an argument. If the user fails to include one argument it should make use of a thread that handles a signal. The signal handler should tells the user Incorrect number of arguments and then calls the terminate signal on the process.

If the numbers of arguments are correct then the program should allocate memory space to the file (5MB) and create a child process that requests the user for a character that it should send to the parent. The child should keep request for data until the user keys in the character O. During each request it should pause for 10 seconds, send the character to the parent and then requesting again for another character.

The parent should get the character from the child. Do not make the parent wait for the child to finish requesting for data. Make use of pipes to facilitate communication between the parent and the child. A second child should be created to read and display data from the file. Make use of any appropriate Inter Process Communication technique to ensure that the second child and the parent do not access the file simultaneously (Mutual exclusion).

View 5 Replies View Related

Programming :: How Some Websites Hide Exact Location Of File On Their File System

Mar 12, 2010

in case you have been wondering how some websites hide the exact location of a file on their filesystem, just thought i'd share it with the commnity at large in case someone else is looking for something like this.i take no responsibility for how it is used.

View 4 Replies View Related

Programming :: Manipulate Application To Look In Different Location For File?

Aug 23, 2010

I have an application which looks in a particular directory for it's settings. For example varsetting.txt. These settings are stored in a text format and can be edited easily. I would prefer to keep this setting.txt file on a USB stick rather than the HDD for portability so that I can easily use the same settings on two linux PC's without having to redit them everytime. I have tried but cannot manipulate the application to look in a different location for this file, do you know if it is possible to "point" linux to another location when looking for the file?

View 2 Replies View Related

Programming :: Shell Script To Delete Files Which Location Should Be Read From Log File

Jun 26, 2010

I have 2 external hdd in wich I have all my files. yesterday, I have copied all the files from hdd2 to hdd1 and I want to eliminate duplicates so I used FSLint to find them,now I want to make a shell script to delete all the files/entries (read from the log file) that begin with.

View 14 Replies View Related

Programming :: Finding A Shell Script To Delete Files Which Location Should Be Read From A Log File?

Jul 16, 2011

I have 2 external hdd in wich I have all my files.... yesterday, I have copied all the files from hdd2 to hdd1 and I want to eliminate duplicates so I used FSLint to find them, now, I have a txt file that looks like this:

Code: /media/My Book/!!!MIS DOCUMENTOS/Documentos/2 sep2003-jun2009 USB/!TESIS/TESIS/TESIS CVT LABVIEW Y CODEWARRIOR/LabVIEW85RuntimeEngineFull.exe /media/My Book/HDD_Toshiba/Borrable/Pen_Drive_4GB/Tesis/Super CD de la tesis/LabView/LabVIEW85RuntimeEngineFull.exe multiplied by millions of entries...

now I want to make a shell script to delete all the files/entries (read from the log file) that begin with:

Code:

/media/My Book/HDD_Toshiba/**** Since HDD_Toshiba is the folder in hdd1 (MyBook) that contains all the files from hdd2

View 1 Replies View Related

Ubuntu :: Write A Base Script Which Will Divide An Argument By 10 And Then Use That Argument In Another Program?

Feb 23, 2010

I'm trying to write a base script which will divide an argument by 10 and then use that argument in another program. Since my argument can be a floating point number, I used bc to accomplish this. Here's an example of a simplified version of what I have so far:

<code>NUM=$(echo "scale=25;$1/10" | bc)
#make sure the first argument was formatted correctly
if [ $? -ne 0 ]

[code]...

View 4 Replies View Related

Programming :: Argument Relations In CGI Script

Feb 15, 2010

I have made fallowing script for CGI scripting learning purpose:

Code:
#!/bin/sh
echo "Content-type: text/html"
echo
CMD='echo "$QUERY_STRING" | sed -n 's/^.*cmd=([^&]*).*$/1/p' | sed "s/%20/ /g" '
echo "<html>"
echo "<head><title>Hello CGI</title></head>"
echo "<body>" .....
echo "<input type=radio name=cmd value=ifconfig checked> ifconfig <br>"
echo "<input type=radio name=cmd value=uname> uname -a <br>"

This script works fine, but actually I quite don't understand it's inner working about those radio buttons.

View 1 Replies View Related

Programming :: Insert $2 Argument Until The End To Variable?

May 17, 2011

how to insert $2 argument until the end to variable?For example:

>> cucu.csh user "long long message "
$1 = user
$2 = "long long message "

View 10 Replies View Related

Programming :: Making A 1 Command Line Argument?

Jun 8, 2010

I need to write a script that will take 1 command line argument. The argument will be a username. The script will determine if the user exists on the system and will print an error if it does not. If the user does exist it will determine if the user is currently logged in, if the user is not logged in it will determine the last time the user logged in and display the file in the users home directory that was most recently modified.

View 2 Replies View Related

Programming :: Passing The Char * Vector Argument?

Jun 19, 2010

I am trying to simulate a shell. So what I do is checking of having the parameters from standard input, suc as "/bin/ls -l /home/france/Documents", and then passing them to function execute, which at some point calls execvp(argv[0],argv)The problem is that I don't succeed in using these arguments, while if I call execvp(paramList[0],paramList) it works!!!! Where paramList is exactly what I would put on standard input, but defined statically.

Code:

#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

[code].....

View 2 Replies View Related

Programming :: [bash] Option Followed By Argument List?

Feb 6, 2010

I'd like to pass the following arguments to a bash script in any order:

Code:
myscript -l <country> -r <file1> <file2> ... -o

I read the argument list in a switch shift loop. I figured out how to read the filelist but only if -f is the last option.

how to position the file list anywhere in the argument list?

View 5 Replies View Related

Programming :: Shell: Give A Range Argument To 'for'

Feb 20, 2010

Feel free to just link to another thread where this is (pre)solved; I can't search the forum for the word "for," because it's too short (or maybe the search engine dislikes prepositions).

Is there a way to give the 'for' command a range? Here's what I mean:

Code:
#for i in (1-5); do echo $i; done
Certainly, meat space user; I understand exactly what you're thinking.
1
2
3
4
5
True, I realize I could use

Code:
COUNT=1 ; while [ $COUNT -lt 6 ]...

...but if I can avoid the extra preparatory step I'd prefer to do so.

View 2 Replies View Related

Programming :: Pass Complicated Commands As Argument To Another Script?

Apr 21, 2010

I am attempting to script some tasks I have to do, but I have no control over one of the scripts I have to use... and they output all kinds of useless things on the screen. My goal is simple: Capture all output from their scripts, and create a progress line that only shows the most recent output from their stuff. So, here was my first solution; a file I called "spin":

Code:
#!/bin/bash
spinX(){
PROC=$1
STRT='date "+%s"'
while [ -d /proc/$PROC ];do
last3=" 'getLine $2' "

To use it, you pass it a process ID and a file that contains the output from that process. As the process continues, a kurby dances on the screen (To let you know that the process has not hanged), and the tail of the output is shown (To let you know what it is doing). When the process ends, the kurby stops dancing and the time it took is displayed.

And here is the file I call "noise":
Code:
#!/bin/bash
while [ i -lt 100 ];do
i=1
echo "Look at me count!$"
sleep 1
let "i=$i+1"
done

This does nothing but create random output, for testing. It counts from 1 to 99 on the screen. To run my test, I do the following:
Code:
(noise) &>tmp.txt & spin $! tmp.txt

It works relatively well, but it is messy. I don't like creating a temp file, and I don't like the messy syntax for calling my program. I decided that I would rather move everything into the spin program, to make using it less messy:
Code:
#Spin Psuedo code
#$1 = command I am about to run
(exec $1) &>tmp.txt & spinX $! tmp.txt

By executing the process inside of the spin code, I can get rid of the tmp file later on without changing a lot of scripts (Or move it, or whatever). I can also call it by passing the command to the script, which I find more elegant.

So here is what I would like to know:
1) If possible, I would love to get rid of the tmp file all together, and store the most recent line of output from script 1 into a variable that script 2 can print out instead... is it possible?
2) How can I run a random command that is passed as an argument? Basic ones work fine, but anything with a pipe fails me.

Example of a script:
Code:
#!/bin/bash
#myEcho.sh
echo;echo "Recieved command: ";echo $1;echo;
echo "Attempting to run command: ";echo
exec $1

Example code for passing commands to script:
> myEcho.sh "ls -al" #works
> myEcho.sh 'ls -al' #works
> myEcho.sh "ls -al|grep *.sh" #fail
# Output:
#ls: invalid option -- |
#Try 'ls --help' for more information.
> myEcho.sh "ls -al|grep "*.sh"" #fail
# Output:
#ls: invalid option -- |
#Try ls --help' for more information.
> myEcho.sh 'ls -al|grep *.sh' #fail
# Output:
#ls: invalid option -- |
#Try 'ls --help' for more information.

View 8 Replies View Related

Programming :: Ssh Remote Command Preserve Quoted Argument?

Sep 17, 2009

I have a python script on one server (serv_one) and I am trying to execute it remotely from another (serv_two). The python script takes an argument with spaces. If I execute it locally:

Code:

foo@serv_one> script.py --o "arg one"
"arg one" is preserved, of course. ( argv = [ '--o', 'arg one' ] )

However, when I execute it remotely:

Code:

foo@serv_two> ssh ... foo@serv_one script.py --o "arg one"

the double quotes around "arg one" are dismissed ( argv = [ '--o', 'arg', 'one' ]. I've tried many combinations of single quotes/double quotes/backslashes, etc, to no avail. One hack solution I came up with, since I have the flexibility, was to replace all spaces in the quoted argument with a character that would be invalid in the argument (before the ssh call), and replace those with spaces in script.py. I would probably like to avoid this solution if at all possible.

View 7 Replies View Related

Programming :: C++ Program Calling A Fortran Subroutine With A Function In The Argument?

Mar 9, 2011

I have a new problem; i want to call a subroutine's fortran which have a function in the argument and the compilation ran properly, but when i execute the program this shows me an "Segmentation fault". This is my c++ program:

Code: //Main.cpp
#include <stdio.h>
#include <iostream>

[code]....

View 2 Replies View Related

Programming :: Handle Non Argument Error While Adding Two Alphabets Using 'expr'

Feb 19, 2011

how to handle non argument error while adding two alphabets using 'expr' (not bc).

View 1 Replies View Related

Programming :: Shell Scripting - Value Disappears Depending On Argument Order

Mar 21, 2011

Examples:
Code:
$ ./test.sh -a -c 2
operator is -gt
remcount is
^ value missing!

Code:
$ ./test.sh -b -c 2
operator is -lt
remcount is
^ value missing!

Yet when "-c" is the first argument, its value is present:
Code:
$ ./test.sh -c 2 -b
operator is -lt
remcount is 2
What could I do to ensure the value of "-c" is picked up regardless of the argument order?

View 5 Replies View Related

General :: Read A Line In A File And Use It As Argument?

Mar 20, 2010

I want to do this

read a files's specific line but return as argument only part of it ie

...

value # this is mass

value2 # this is force

so, how can I get / use the $value and $value2 as arguments for some other file and skip the rest of the line(s) ? of course, the values are different everytime, but the comment always the same, as well as the position of the lines in the file

View 4 Replies View Related

Programming :: Make A Template Char Or Wchar_t Default Function Argument?

Oct 30, 2009

I have a template similar to the following.

Code:

template <charT>
virtual void do_get_date(charT* = "str")
{ ... }

As you can see we have a problem. If we use a wchar_t instead the string wont be formatted right we need to prefix L in front. If we use char16_t we need to prefix a u in front. Is there a was to make the generic without resorting the the std::string class?

View 2 Replies View Related

General :: MV - Missing File Argument (Moving Files Within LAN)

Feb 1, 2010

Objective: To move or backup all the 30 days old files to the other server within LAN. I have tried testing it first within the server by performing below commands:
find /usr/test1/* -mtime +30 -exec mv {} /usr/test2/ ;
But I'm getting "mv: missing file argument" error when I try this.

View 1 Replies View Related

Programming :: Bash Shell Read User Argument From Command Line And Test It

Aug 29, 2010

Trying to create a small script that will read user's input, test if user entered some input and if not display some message or display a text using user's input.

The script is the following but i get an error saying "[: 6: =: argument expected"

View 12 Replies View Related

Programming :: Location Of - Gnu - C++ Standard Library

Jul 21, 2010

Where is the location of the header files for the c++ standard library?

I assume that they were installed by gnu g++, please correct me if i'm wrong.

I'm running ubuntu 10.04 with g++ 4.4.

I looked in /usr/lib/gcc/i486-linux-gnu/4.4/include, but this directory contains only the following:

Code:

Which doesnt seem to include the really basic things like iostream, for example.

Where can I take a look at the header files for these standard c++ libraries?

View 2 Replies View Related

Programming :: Byte At Memory Location 45 With Immediate Value 03

Jul 10, 2011

As 2.17
I want to code this:
and byte[45],03

In words, AND the byte at memory location 45 with immediate value 03. As reports "Ambiguous operand size for and". How could I code the instruction such that as understands my intention?

john: .byte 45
and byte[john],03
gives the same error.

View 8 Replies View Related

Programming :: Vfprintf In 64-bit Environment - Warning: Passing Argument 3 Of Vfprintf From Incompatible Pointer Type

Apr 14, 2010

I want to use vfprintf with the char * on 64-bit. Here is the sample code:

[Code]...

In this code, I am getting warning: passing argument 3 of vfprintf from incompatible pointer type I have done sizeof(va_list) on 64-bit, and its 24 bytes. I don't know how am I suppose to use the va_list this way.

View 1 Replies View Related

Programming :: Warning: Pointer Targets In Passing Argument 1 Of "STRING_stricmp" Differ In Signedness

Jul 13, 2011

i have this warning "differ in signedness".

[Code]...

so i was getting this error. im thinking it may be because of somewhere i declared unsigned and signed so this signedness warning occurring.

Code:

switcase.c: In function ImplementDebugCmd: switcase.c:385: warning: pointer targets in passing argument 1 of STRING_stricmp differ in signedness

View 1 Replies View Related

Programming :: Finding Location Of Duplicate Directories

Jan 8, 2011

This simple task is proving harder then imagined. I have a multi-level directory that I'm trying to clean of duplicates, but I can't get 'find' to print what I need to see. To give an illustrative example, here is a dir:

Code:
stuart@stuart:~/testdir$ ls *
dir1:
level2:
dir1

So the output of find as i'd like it to work would show the two locations of dir1, which would be ./dir1 and ./level2/dir1. But no:

Code:
stuart@stuart:~/testdir$ ls -d */ | head -1 | find . "`cat`" -type d
.
./level2
./level2/dir1
./dir1
dir1/

View 2 Replies View Related

Programming :: Write A Value From A Specific Memory Location In C?

Jul 13, 2010

How to write a value to a specific memory location in C language and how to access the same value ?
I am trying the same on fedora linux and i am trying to write the value to the 32-bit address.

View 2 Replies View Related

Programming :: Codeblocks Plugins And Header Files Location?

Jan 29, 2010

I installed Codeblocks and build some programs, but I have two questions:1. Where are my header files placed, since I don't know where codeblocks is installed. Soemetimes I have to remove header file extension (.h) to be able to compile some source. I use gcc as setting for codeblocks to compile and build programs.2. Plugins for Codeblocks can be installed, but when browse codeblocks's wiki I can't find download links neither developer pages

View 3 Replies View Related

Ubuntu :: Copy File To New Location?

Nov 29, 2010

File is named similar to : logout 10.10.10 100817.txt

I need to copy this to a new directory.

To fine the latest file I was advised to use code...

View 3 Replies View Related







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