Programming :: An Assignment: Writing A Bash Script
Oct 2, 2010
I have assignment to write bash script and I have to submit it after tommorow . I do not have experience to finish it by myself.I am really need help if any one can contact me. on my email I will be thanks him/ her.
View 14 Replies
ADVERTISEMENT
Mar 11, 2010
Here the description of the issue I am having.I am writing a bash test script which reads lines from a file, builds ISO messages, sends them to a server, reads the response with response code and reports the result of the test to a file or on the screen.The message that I need to send is 94 characters long.Here's the portion of a code that I initially wrote:
~ Open socket.
exec 3<>/dev/tcp/172.26.0.25/9991
#~ Send msg.
[code]...
View 7 Replies
View Related
Jan 5, 2011
I have been trying to write a simple snip of bash shell code to import from 1 to 100 records into a Bash array.
I have a CSV file that is structured like:
record1,item1,item2,item3,item4
record2,item1,item2,item3,item4
record3,item1,item2,item3,item4
record4,item1,item2,item3,item4
And would like to get this data into corresponding arrays as such:
$record1[item1-4]
$record2[item1-4]
$record3[item1-4]
$record4[item1-4]
View 9 Replies
View Related
Nov 29, 2010
I have a text file (myfile.txt) with columns a,b,c.
123 2 23
124 2 24
125 2 22
[code]...
View 4 Replies
View Related
Feb 9, 2011
I have it so that an Env object contains all the variables in the current scope, and the parent scope. You can also save them to variables like objects, and my idea is to use the "." operator to get values from them.
First, how do I assign to them? I currently have it that only a variable name can be assigned to, but you should be able to assign to an "obj.value" expression, too. How do I keep track of what variable to set and still be able to say it in an expression and have it evaluate to the variable?
Second, these object don't really have a "type", they're just containers that contain any values you want under any name you want. How can I, for example, define a primitive "boolean" object and have things like if statements recognize it?
View 14 Replies
View Related
Feb 3, 2011
it's been a long time since I did coding in C, but thought to pick up a very old project again, just to show off what I have been working on ten years ago.I deducted my problem as follows:
Code:
#include <stdio.h>
#include <stdlib.h>
#define bit1 1
#define bit2 2
[Code]...
Why is it saying that bar->act is not a valid lvalue while both bar->act and the bit are cast to (long long)?
View 6 Replies
View Related
Sep 26, 2010
does the assignment operator copy all the members also for structures containing STL objects strings,vectors,vectors of vectors...)? I did try it on my platform,and it works that way (copying all the fields),but i was wondering if it is a standard behavior or not.
View 2 Replies
View Related
May 6, 2011
When you are performing time consuming operations in bash like installing new software, is it possible to write text that will appear at the prompt when the operation has finished.
E.g
Imagine running:
apt-get install eclipse-platform
Then it will use quite a while to finish while you see the installation log, meanwhile I want to create new folders (workspaces) which Eclipse later will use.
Is this possible without opening a new terminal (or tab)?
View 5 Replies
View Related
Dec 7, 2009
I was assigned to write a bash script in backtrack which will reveal the active IP Addresses on a /30 network. Normally I would not have a problem with this, but I just dont understand because would you not need the entire prefix (ex: 192.168.1) in order to ping sweep for a certain IP range?basically what I'm asking is...How do I nmap a list of IP's for a "/30 network" as that's all that we're given.
View 3 Replies
View Related
Aug 10, 2010
I am about to write my first shell script for backing up my server.
These are the steps I have identified so far.
Copy files to be backed up to /srv/backup/ run mysqldump and copy the file to srv/backup/databases run duplicity to backup /srv/backup/* to another folder on my machine
I am writing a bash shell scrip that will be run everyday, and will carry out the three tasks mentioned above.
Note: point 3 (backing up to a local folder) is only a temporary measure - to allow me to understand what I'm doing, since all the tools I am using, are new to me. Once I can backup and restore correctly, I will use duplicity to compress and encrypt the files and upload them offsite.
If my understanding of duplicity is correct (according to the documentation here), the first time I run the script, a FULL backup will be done. Every subsequent backup will then be incremental. I will then force a FULL back on say a weekend.
First things first though - I have a few questions:
I would like to use backup rotation for the 'scheme' described above - I would like some recommendations on what kind/type of rotation to use. Once I have implemented the backup rotation, how can I restore from a particular day back in time (assuming the backup exists of course). ?
I am running Ubuntu 10.0.4
View 1 Replies
View Related
Jul 6, 2011
I got across a peculiar problem with memcpy.History:writing a code which do flash/Read functionality for SPI Parts.
Implementation:
1.memory map the Flash chip registers to userspace. - fine
2.Issue block read command
3.Just print the data I got, using the memory mapped address - fine I got the correct data.
4.Copy the data to a local buffer from memory mapped address using memcpy - FAIL
UPDATE:
on SUSE 11.3 -32 bit the above code worked perfectly, but on SUSE 11.4 - 64bit , Ubantu, Fedora it failed.
I am using gcc compiler obviously. I am using i386/x86_64 OS. Processor: Intel core 2 duo, SNB after step 4 , when I dump the data from local buffer every thing is FF.But step 4, if i implement byte by byte copy using assignment operator, it worked.is there any known bug with memcpy? am I missing anything?
View 7 Replies
View Related
Jun 11, 2011
I'm on a Dell Inspiron 6000. I installed i8kutils and it works. Fan speed reduces CPU temp from 50C to 44C. A start-up script invokes the i8k module: $ udo /usr/sbin/modprobe i8k force=1 which creates /proc/i8k. The man page for i8kctl is straightforward: a few simple commands to read info from the aforementioned file.So. I know nothing about writing even basic bash scripts. I gave it a go here but I know this is way wrong. Would anyone like to help a guy out? This is my starting point (don't laugh):
Code:
#!/bin/bash
# script to toggle fan speed low/high
[code]...
View 5 Replies
View Related
May 2, 2011
I am going to write a TCP server program using c. Can anyone give me some advices on whats and what not to do specially when using select?
There would be a lot of data to be transferred both on the server and back to the client. I already have a simple server here but the server uses a lot of resources. Maybe 3 to 4 connections and the server's load would rise to unacceptable levels.
Which do you think is better to use fork or select?
View 4 Replies
View Related
Apr 21, 2010
I want to write some PHP for a website that'll have the data that the script will generate written inside a table with thin black line around it, much like LQ itself. My problem is: how do I draw the box that the text will be inside of, since the amount of text will vary - if I have a GIF with a picture of a box, that'll be of a fixed length, and my script can then only generate that much text, for it to look nice. Or do I need to fiddle with the GD library to get done what I want?
View 4 Replies
View Related
Mar 17, 2011
This loop is part of a bash script which takes multiple arguments.
Code:
for ((i=1;i<=$number;++i)) ; do
offset=$(($i+5))
[code]...
View 3 Replies
View Related
Aug 11, 2010
So basically, there is a really cool writing system I have been working on. It could be viewed (for simplification purposes) like an encryption method for the Latin script.
Facts about the writing system:
It has a little over 300 symbols.
It is syllable-driven.
It is highly compositional (eg. "c", "ca", "cae", "ca " and "ci." all map to different symbols - and NOT by overlaying elements)
Symbols have medium graphical complexity (comparable to Korean Hangul, or Japanese Hiragana)
Has a rather complex set of diacritics (~10, some of which can go on any symbol)
Has no ligatures
How transliteration occurs:
Sequences of Latin symbols map to certain symbols. Example below:[G][rou][p ][hu][g.]Characters sequences between "[" and "]" map to a single symbol (so it would take only 5 symbols to write "Group hug.").
How I want it to work:
I would like to have a daemon that: Intercepts all text displayed on the screen.
Converts it to my writing system (changes letter sequences with individual Unicode codes)
Leaves unsupported symbols unchanged.
Displays all the text on the screen using my font and characters intertwined with the fonts and characters left unchanged.
For example, if you take the following line of C++ code:for (i = 1; i <= n; i++)
I would like it displayed like this:[fo][r ]([i ]= [1]; [i ]<= [n]; [i]++)
Bold-symbols should be in my Unicode font with special symbols defined for this writing system, and the rest should be in its original font and encoding. Also, I would like this encoding to hold for display-purposes only. The data in the memory should remain unaffected. This also means real-time adjustments: if I open a text editor (say, from the OpenOffice Suite) and I start typing, I would like to see what I type encoded with my writing system, even though the document actually contains Latin letters. This also means that the symbol immediately before the cursor may change as you type.
View 3 Replies
View Related
Apr 27, 2011
I have written a daemon server. I would like to add the ability for the daemon to update itself. That is, it should be able to download the latest version of the code (when it receives a signal from a client) and then restart itself. I am stuck on getting the daemon to restart itself. The problem is killing the old daemon without killing the process that is starting the new daemon. In my latest attempt, the daemon that is updating itself runs a program in a subshell (using system) that starts a restarter daemon that runs the original daemon (again using system) with the restart command option. With the restart option, the new version of the daemon sends a terminate signal to the old version. Obviously, when I run the original daemon manually with the restart option, it restarts reliably. I figured that issuing the same restart command from a daemon would adequately isolate the process doing the restarting from the program being restarted. Using ps, I can see that the daemon does actually restart. However, the client locks. In fact, a few times, the OS locked and I had to reset.
View 7 Replies
View Related
Apr 9, 2011
How to write a mkdir with -p option. I am struggling for creating subfolders. the chdir() is not working and thus subdirectories can't be created.
Code:
View 1 Replies
View Related
Apr 10, 2010
I'm not able to write to a file using my perl cgi script which is as fallows:
Code:
#!/usr/bin/perl -w
use strict;
print "Content-type: text/html
[Code]....
View 4 Replies
View Related
Feb 28, 2010
I am trying to write .pgm images using the O_DIRECT flag in open().I have a char* buffer which has the image data. I know that I have to align the buffers and have done that using posix_memalign() yet only a part of the image gets written.Has someone used O_DIRECT for writing files successfully?
View 1 Replies
View Related
Jul 7, 2010
I'm trying to write a simple, console based application in linux, in c++. I know how to start in Eclipse and I have some experience in c++ from Windoze. I would like to ask, if there is some tutorial available on writing console apps. I mean, I know from using linux that there are two conventions on using parameters in command line (-v and --version for example).
View 2 Replies
View Related
Mar 19, 2011
My platform is linux Centos 5. I have read that to learn programming is to read well-written code and take some project to work with. I am always fascinated by routers and firewalls. Like pfsense and vyatta. May be my searching skills are worst but i am not able to find any good tutorials. Ofcourse i dont expect anyone to write a complete router on their blog but wasnt even close to it.
View 1 Replies
View Related
Feb 4, 2011
I would like to know how do I print the line # in a script. My requirement is, I have a script which is about ~5000 lines long. If there are any errors happen I just exit. And I would like to add the line # of the script where the error happened.
View 3 Replies
View Related
Jan 24, 2010
simple bash code:
Code:
#!/bin/bash
trap "echo 'you got me'" SIGINT SIGTERM # to trap ctrl+c
echo "Press ctrl+c during 5 sec loop"
for ((i=0;i<5;i++)); do
[Code]...
How come code behaves normally and stops when ctrl+c signal is caught and resumes, but after I use at least one timeout read in the code it looks like, if signal is caught again it doesn't pause the execution but skips the loop. If you remove -t (timeout) option from the read, both loops look the same!
View 10 Replies
View Related
Nov 11, 2010
I am running a java application on centos. For now I have a gsm modem connected via the the usb cable. Below is the message I get when I type the command dmesg | grep tty
serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
00:0c: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
usb 2-2: pl2303 converter now attached to ttyUSB0
[code]....
View 9 Replies
View Related
Jun 3, 2011
Code:
int main ()
{
[code]...
View 9 Replies
View Related
Jan 1, 2011
Reading and writing text files in C?
View 9 Replies
View Related
Dec 3, 2010
I would like to write a program that can read every ethernet frame arriving on a specific hardware NIC, without a TCP/IP stack otherwise doing anything on that NIC. Likewise I want to be able to write out to that NIC. So every arriving ethernet frame, of all types, would be readable (probably one at a time to preserve frame boundaries). And every write of exactly that same data would send frames out. The data read and written would be the whole ethernet frame. The kernel would do nothing else with this data, but other NICs would still operate as usual.
What I would be doing is that on 2 separate NICs, copying frames from one to the other, as in bridging. But I would also be doing modifications per what my program needs to do (not at liberty to say what that would be). What facility would I need to be looking at to do this? There is no ethernet device file. Would raw sockets be able to do this? The programming language will be C.
View 4 Replies
View Related
Nov 10, 2010
I created a small C++ program which starts a server in a separate thread and waits the user to press q using the standard input/output. Something like:
Code:
printf(...);
server->Start();
[code]....
View 8 Replies
View Related
May 28, 2010
I am trying to learn how to write a kernel module. I am following the excellent guide from The Linux Documentation Project called The Linux Kernel Module Programming Guide v.2.6.4.
My machine is running Ubuntu Lucid Lynx (10.04)
Code:
I installed the corresponding linux headers and just to make sure I also installed the linux source and extracted it in /usr/src
I am trying to run the following trivial kernel module
Code:
View 4 Replies
View Related