LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 10-02-2009, 09:46 AM   #1
zeus65
LQ Newbie
 
Registered: Oct 2009
Posts: 3

Rep: Reputation: 0
Using dd command to create a .sequence file


Hi Everyone, firstly like to say Hi can't say how many times I've randomly searched for something via google and got the answer on this forum... its a lot

I know there is a major thread on how dd works but I'm really confused by it in terms of what I'm trying to do


Basically I've inherited this concept where say in a dir
/var/spool/send

a person runs this command dd if=/dev/zero of=.sequence bs=8 count=1


Now what I inherited is a binary c file that can lock this .sequence, print out the number 'stored', and bump up the number. Unfortunately I don't have access to the original c code source currently and considering I'm just trying to duplicate into java.


e.g
first time program runs it just prints out

00000000000000000000


second prints out

00000000000000000001

The idea is to create a sequencing filename mechanism. So if I was spooling a bunch of files to a web service or some sort of socket the program writing to the files would first use 00000000000000000000 as the file name then 00000000000000000001 for second ...



Now I'm trying to figure out how this was done in the c program and actually do the same thing in java.

I noticed something in the forum message but I'm not sure how it correlates

zeus@pandion:~/tests$ hexdump .sequence
0000000 0002 0000 0000 0000
0000008


Thanks guys this is probably something so simple but...
 
Old 10-02-2009, 11:57 PM   #2
JulianTosh
Member
 
Registered: Sep 2007
Location: Las Vegas, NV
Distribution: Fedora / CentOS
Posts: 674
Blog Entries: 3

Rep: Reputation: 90
It seems there's a bunch of unnecessary information in this post. Can you confirm my interpretation please?

You want a java program to open a file, read an integer, increment it, write it to the file, and then display it?
 
Old 10-03-2009, 03:37 PM   #3
zeus65
LQ Newbie
 
Registered: Oct 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks

Hi Admiral yeah pretty much. I was just trying follow the same mechanism we have today in the system. Guess it doesn't really need to rely on a dd sequence file at all when you put it like that .
 
Old 10-03-2009, 06:08 PM   #4
JulianTosh
Member
 
Registered: Sep 2007
Location: Las Vegas, NV
Distribution: Fedora / CentOS
Posts: 674
Blog Entries: 3

Rep: Reputation: 90
I know you asked for it in Java, but here it is in a bash script:

Code:
#!/bin/bash

if ! [ -f tmp/.sequence ]; then
  echo 0 > tmp/.sequence
fi

counter=$(cat tmp/.sequence)
counter=$(($counter + 1))
echo $counter | tee tmp/.sequence
 
Old 10-05-2009, 04:38 AM   #5
zeus65
LQ Newbie
 
Registered: Oct 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks Admiral that is pretty much what I will use.


Jason
 
  


Reply

Tags
dd


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Are results sent to an output file only at the end of a command sequence? Zebe Linux - Newbie 2 03-19-2009 06:34 PM
how do i create an empty bash(.sh) file in command line? bbmak Linux - Newbie 1 10-26-2007 02:39 AM
create linked file by command ,how ? silvercloud General 1 09-07-2005 07:38 AM
Linux shell command for makefile.in to create a text file and write to it alix123 Programming 8 01-07-2005 08:18 AM
how to create the .profile file.what command?thanks:) kenisalen Linux - Newbie 1 11-06-2002 09:57 PM


All times are GMT -5. The time now is 04:10 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration