Programming :: Dynamically Supply Input To Netcat In A Script?

Mar 5, 2010

I am trying to write an irc bot to run interactive fiction games in a channel. I am connecting to the channel using nc. I'm having a hell of a time trying to supply input stdin for nc after the connection is established. Here's what's going on. I've got lines of plain text in a file with the irc commands required to identify the bot's ID and join the channel. I can connect easily using any of the following commands

cat inputfile | nc irc.servername.org 6667 -i 1
nc irc.servername.org 6667 -i 1 < inputfile
Named_Pipe | nc irc.servername.org 6667 -i 1
cat inputfile > Named_Pipe

With the first two commands nc connects, reads the file with some time between each line allowing the irc server to respond, bringing me into the channel. It then begins to receive stdin from the command line allowing me to do things like "privmsg #channelname :Hello World!!!" sending messages to the room. This is not the desired behavior. I require nc to take additional stdin from the inputfile if I cat additional text to the end of it.

The last set of commands using the named pipe seem like it does the same, but it doesn't actually send anything to the room, which indicates to me that perhaps nc is continuing to take stdin from the named pipe (this is the desired behavior) rather than dropping to the console for stdin. If I try to cat more plain text data to the end of the named pipe, however, either with something like "echo 'privmsg #channelname :Hello World!!!' > Named_Pipe" (or >> instead of >) or with a filename in place of the "echo" command the whole command simply seems to hang until I press ctrl-C.

I don't understand what I'm doing wrong. With anonymous and named pipes, and with redirection, the problem seems to be the same. nc seems to take it's stdin from the file until it hits the end of file, at which point I can no longer introduce new lines of plain text as stdin for the running nc process.

View 4 Replies


ADVERTISEMENT

Programming :: Dynamically Loading Libraries In GNU?

Oct 22, 2010

This post isn't really asking for a tutorial, but rather asking for some ideas. I've come up with a few ideas, but they seem cumbersome and unnecessary, so I was wondering if someone with more experience than me could out. Also, my explanations suck, but I'll try to do my best. So say I have an executable called X. At some point during its execution, X loads and uses (using dlopen and dlsym) a library called Y. In Y, there a bunch of functions that call the function called, for example, void *special_malloc (size_t). These functions come from another linked library (linked during compilation) called Z. Problem is, special_malloc contains some static variables within its scope, and when those variables are reset midway through a program, an invalid free occurs (special_malloc uses garbage collection). Now, what I want to happen is that whenever lib Z calls special_malloc, it instead calls the special_malloc defined in the executable X, so that these static variables are retained. Keep in mind that I have control of the Z library, meaning I can edit the source to fit my needs.

View 2 Replies View Related

Programming :: Make A Bash Script That Will Open Up Port 23 For A Netcat Connection?

Apr 14, 2009

I'm starting to like making bash scripts. It's kewl making creative ones. Right now I'm trying to make a bash script that will open up port 23 for a netcat connection. Once there's a connection, I'd like for the script to open up xmms and play a sound effect, as well as echo a txt file to the desktop saying that a connection was made at this specific time. When I execute the script, it stops exection at the first line. So far I have this:

sudo nc -lvnp 23
while [ 1 ]
do

[code]...

View 8 Replies View Related

Programming :: Bash - Read The Array Dynamically?

Sep 24, 2010

Code:

test=(1 2 3 4 5)
for car in ${test[@]}
do
echo "Element : $car"

[code]....

if variable $car equals 1, new element is added "6" to an array. But i don't know why when i am printing all elements of this array (echo "Element : $car") this element ("6") is not mentioned, but if i make a command which check an amount of contained elements by array it will be 6 elements.

View 14 Replies View Related

Programming :: How To Call Array Dynamically Into Script?

Jul 20, 2011

I have a script which takes an array as an input to the file.ex: test.ksh -l <array_value>

Every time I dont get the same array name.EX: test.ksh -l x ; where x="a b"test.ksh -l y ; where y="c d"

I store the value I get in l in varaible myLvalue.Now indise my Script I want to run a for loop for thevalue I get in -l.If I write the for loop as below. I'm getting value x.However I'm expecting the loop to run for a and b.

View 5 Replies View Related

Programming :: Java : Use Dynamically Loaded Classes?

May 15, 2010

I'm new to Java.
I'm trying to use some dynamically loaded classes in my application.
The application doesn't know those classes , Just it try to load a class by name that its name came from input.
It doesn't know class (So I can't use casting) but just needs to call some methods of that class (every class should have that methods).
I thought about interfaces but I don't know how.
How can I call those methods?

View 1 Replies View Related

Programming :: Link One Library Statically Others Dynamically - Gcc - G++

Jul 6, 2011

I would like to make gcc to link one lib (pthread in the example) statically, and the rest dynamically.

(See the example .c file at the end of this post.)

compiles fine, but every lib is linked dynamically.


Now every lib is linked statically

Not a dynamic executable

I would like to link the libpthread statically and the rest dynamically. Is it possible?

[url]says if I give the full path to the .a lib then it will be linked statically:

So for me it does not work.

On other sites I found that I should use -Wl,-Bstatic -lpthread -Wl,-Bdynamic, but it also doesn't work:

So, how can I do that?

Machine: Linux 2.6.16.60-0.27-bigsmp #1 SMP Mon Jul 28 13:06:32 UTC 2008 i686 i686 i386 GNU/Linux SLED 10

As an example I used a little demo program from [url]

Here is the code:

View 4 Replies View Related

Programming :: Local Dynamically Allocated Array In Fortran?

Oct 19, 2009

I (my friend) have a fortran program with the code along the following lines:

Code:

SUBROUTINE NY
REAL, DIMENSION(4000,4000) :: a, b, c
...
RETURN
END SUBROUTINE PARAMETERS

The problem is that the huge matrices are retained in memory even after the subroutine ends. Is there an easy way to declare the arrays in a sort of dynamic way, like they were in the following C example?

Code:

void ny(void) {
double a[4000,4000];
...
}

I mean in the C example the memory is released as soon ny() exits.

View 5 Replies View Related

Programming :: Get Path Of One Library To Link It Dynamically In Program?

Apr 28, 2010

I'd like to get path of one library to link it dynamically in my program. Probobly the best way would be to add macro to my configure.ac file.

View 2 Replies View Related

Programming :: Python: Dynamically Create A List Within A Dictionary?

Jul 9, 2011

how to dynamically create a list within a dictionary using Python.

Code:
dates = defaultdict(int)
array = []
...
dates[m.group(3)] = array.append(date)
dates[m.group(3)] = [array.append(date)]
dates[m.group(3)].append(date)

None of the above works and I've tried everything I can think of.

View 3 Replies View Related

Programming :: Wrote A Driver That Scans On Startup Dynamically For Available EEPROM's On A Certain IC Bus?

Jul 28, 2011

I wrote a driver that scans on startup dynamically for available EEPROM's on a certain IC bus. For each EEPROM a new character device is created in /dev like:

/dev/bus0eepromA0
/dev/bus0eepromA1
/dev/bus0eepromA2 ...

[code]....

View 1 Replies View Related

Programming :: Unable To Dynamically Create An Array Of Params For Execv In C

Jan 6, 2011

I haven't programmed in C for a while, so I am trying to remember certain aspects of syntax. I have a program that will fork and exec other programs. Those programs will be specified on the command line as follows:

./main "prog1 arg arg ..." "prog2 arg arg ..."

Here is the main snippet:

int countChar(char* s, char c)
{ int cnt = 0;
int len = strlen(s);
for(int i = 0; i < len; i++)

[code]....

The highlighted line is the problem. I get this error:

dualstarter.cpp:58: error: initializer fails to determine size of 'params'.

Right now I am thinking of creating an array with the specified size and simply copying the required string into it, but it just seems like there is an easier way.

View 9 Replies View Related

Programming :: Read Any Given Maze.txt Into An Internal Dynamically Allocated Array Of Strings?

Apr 26, 2011

I am looking for an easy way to convert any given maze.txt of any size to a internal array of strings(dynamically allocated). Important is that dimensions of the maze (row, col) shouldn't be written by the user instead they have to be somehow read from the file. This is not my homework assignment! It is a small part of a project that i never dealt with. I never read files to C string.... I made it for specific maze dimensions, but want it to work with any given .txt file.

View 9 Replies View Related

Programming :: Save / Load Data Segment Of Dynamically Loaded Shared Object Library?

Aug 25, 2010

Our application uses a dynamically loaded shared object library (codec library) to compress and decompress audio streams.

There happens to be several static and global variables in this shared object library. Hence it is not possible to process two interleaved unrelated media streams using this shared object codec library because each stream corrupts/changes the contents of these static/global variables.

Is there a way through which a context save (save contents of data segment of shared object) and a context load (load previously saved contents of data segment of shared object)operation can be performed on the shared object library. This way the context for each media stream can be saved and loaded before and after processing the "other" media stream respectively.

View 3 Replies View Related

Programming :: Jquery To Dynamically Create Cookies Using The Jquery Cookie Plugin?

Jul 27, 2011

I am learning jquery and I think for the most part I have the basics down. One of the things that I am attempting to do is to create cookies using the jquery cookie plugin. The idea is that I want to replace as much of the javascript in my code as possible with jquery to see the difficulties in doing it one way or the other.

As easy as it seems to be able to create a cookie using the plugin I have not been able to do some successfully and the only thing that I can think of is the way that I am submitting my parameters is not correct. So with that, here is is my code:

[Code]...

View 5 Replies View Related

Programming :: Shell Programming - Delete User Input

Jan 21, 2011

I recently started shell programming and my task now is to do a menu display.Currently i am stuck whereby user will input both title and author and it will delete it.

Do i have to use sed command?

View 4 Replies View Related

Programming :: Input And Output On C++ Programming ?

Jan 28, 2010

As i am new to C++ i couldn't figure out how to input a file and make some change on the file and produce a output file. like this problem i have is.

"Program that processes an input file and produces an output file. The input file will contain lines of data, each containing two floating point numbers. The lines of the output file should contain the two numbers read and their average (with a '$' sign and 2 places after the decimal point)."

View 2 Replies View Related

Programming :: Get Input Without The Terminal?

Apr 1, 2010

I've done a little program, it's the snake game. I use an X window to show the snake and all that but the input is taken from the terminal. That means that what I have to do to play the game is open it with the terminal and then the game opens but then I have to go to the terminal again to move the snake. if I open the game from the GUI I can't do anything because it doesn't take my directions. What do I have to do in order to get the program to have a connection with my keyboard? I use getchar() to get the input, maybe there is something else?

View 9 Replies View Related

Programming :: Get Input From Entry Using Gtk?

May 2, 2011

I'm trying to make a program to simulate a parabolic movement, so i've added 2 entries, one for the initial velocity and other for the angle, anyway you probably don't care about that xD what i want is to take the number entered in the entry and put it in a variable to do the math, and then show everything in a dialog or something. how do i do that?

View 3 Replies View Related

Hardware :: Disable +5V Supply On USB And Enable It Again?

Sep 16, 2010

know whether it is possible to disable +5V supply on USB and enable it again?

View 4 Replies View Related

Programming :: Can Diff Take Arrays As Input

Jun 19, 2010

Does diff not like arrays? How do achieve the following?

Code:

stuart@stuart:~/music transfer$ diff file1.txt file2.txt
1c1
< bonkers_in_phoenix.mp3

[code]....

View 14 Replies View Related

Programming :: Checking Input Is Numerical?

Jan 18, 2010

what i am trying to do is to allow the user to key in data such as "23.23" or "24" , as it is the price of certain objectsHow am i able to design a check which will allow me to prevent users from typing in input such as "ab.21" or "rfrr" as this field is purely a numerical field. The problem i am facing is i tried using this search code.

Code:
echo "read this"
read this

[code]....

View 14 Replies View Related

Programming :: How Sed Can Catch Variable From Input?

Feb 2, 2011

right now i am writing bash script for simple everyday todo tasks.script consisit of two files, fisrt is just script (which can delete/append /clear) and second one is todolist.txt which stores my notes.I am litlebit confused about sed!!for example, If my todolist.txt have these lines:

- Writing my Homework
- take my girlfriend to launch
- Take a break

How can sed take my input $@ and delete all line with name "Homework"..i trayed with many sed combination like:

Code:
sed s/$@//g
sed 'd/$@/'
and many more combination with ""/'' or bracket but nothing helped

View 5 Replies View Related

Fedora :: OT Setting Up A Router To Supply Wireless ?

Jun 11, 2010

I will be staying at a hotel for a couple weeks that has a wired internet connection to each room. I have a Linksys WRT54G v6 wireless router and would take with me and set it up so I would have wireless in my room.

View 2 Replies View Related

Ubuntu :: Power Supply Cooling Fan Won't Down Normally / Remedy This?

Oct 22, 2010

I just recently installed Ubuntu and my power supply cooling fan won't power down normally when I would run windows tho it would power down after the system was finished starting up. How can I remedy this?

View 1 Replies View Related

Hardware :: Fanless Power Supply Unit ?

Jan 15, 2011

Does anyone had any experience with fanless, low-powered power supply units (PSUs)like PicoPSU? Please share your experience.

I am also interested to hear about experience concerning the fanless cooling solutions and/or power-scaling for low-end CPUs like Intel's Atom, AMD's Neo or Via's Nano.

View 13 Replies View Related

Hardware :: Using One Power Supply For Multiple Motherboards

Apr 19, 2011

Is it technically possible to use just one power supply for more than one motherboard?The reason for asking is that I have a number of old (a few years) boards that I would like to use to make up a blender render farm yet only have one spare PSU. Having looked at the pin spec URL...pin 16 (power on) should only be connected to one board (or have a manual switch to ground for on)Pin 9 (standby +5v) probably should only connect to the one board or none and the other (or all) boards would need pin 9 to be tied to a +5v pin.All the boards would network boot and have nothing connected to them, no disks, floppies, monitors, etc; as all data would reside on a network server.

View 3 Replies View Related

CentOS 5 :: Can 'officially' Supply These Packages And Their Associated Dependencies?

Dec 4, 2009

The upstream provider is supplying samba3x (currently samba 3.3.8) packages in their supplementary repository. I know that most of what is in the supplementary repository is burdened with restrictive or non-free licenses, however, Samba is not.

The samba3x packages are critical for Windows Server 2008 trust relationships as well as Windows 7 client support for a CentOS server acting as a Windows domain controller. I know that I can either roll my own packages or compile from source, but an officially supported version would be a much better option on a production server.Is there any way CentOS can "officially" supply these packages and their associated dependencies?

View 19 Replies View Related

Debian Programming :: Serial Input In Scripts

Jun 10, 2013

I need a way to use serial input such as through an Arduino in Debian scripts, in any usable language.

View 2 Replies View Related

Programming :: User Input Bash Script

Apr 28, 2010

I've written a bash script that allows a user to input a directory location to find out the size of the directory. However, if the user inputs a directory and finds its size then inputs another directory then wants to quit, the script asks the user numerous times if he wants to quit!! The script won't exit until the number of times the user looks at a directory is reached! What gives?

Here's the script:

Code:

View 4 Replies View Related







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