hi i have pattern like below
hi
hello
hallo
greetings
salutations
no more hello for you
i am trying to replace all new lines with tab spaces using the following command
sed -e "s_/\n_/\t_g"
but its not working .
could nybody pls help?
i need the solution in sed /awk.
I am trying to write a simple bash script that is listening on a port and responding with a trivial HTTP response. My specific issue is that I am not sure if the port is available and in case of bind failure I fall back to next port until bind succeeds.
So far to me the easiest way to achieve this was something like:
for (( i=$PORT_BASE; i < $(($PORT_BASE+$PORT_RANGE)); i++ ))
do
if [ $DEBUG -eq 1 ] ; then
echo trying to bind on $i
fi
/usr/bin/faucet $i --out --daemon echo test 2>/dev/null
if [ $? -eq 0 ] ; then #success?
port=$i
if [ $DEBUG -eq 1 ] ; then
echo "bound on port $port"
fi
break
fi
done
Here I am using faucet from netpipes Ubuntu package.
The problem with this is that if I simply print "test" to the output, curl complains about non-standard HTTP response (error code 18). That's fair enough as I don't print HTTP-compatible response.
If I replace echo test with echo -ne "HTTP/1.0 200 OK\r\n\r\ntest", curl still complains:
user@server:$ faucet 10020 --out --daemon echo -ne "HTTP/1.0 200 OK\r\n\r\ntest"
...
user@client:$ curl ip.of.the.server:10020
curl: (56) Failure when receiving data from the peer
I think the problem lies in how faucet is printing the response and handling the connection. For example if I do the server side in netcat, curl works fine:
user@server:$ echo -ne "HTTP/1.0 200 OK\r\n\r\ntest\r\n" | nc -l 10020
...
user@client:$ curl ip.of.the.server:10020
test
user@client:$
I would be more than happy to replace faucet with netcat in my main script, but the problem is that I want to spawn independent server process to be able to run client from the same base shell. faucet has a very handy --daemon parameter as it forks to background and I can use $? (exit status code) to check if bind succeeded. If I was to use netcat for a similar purpose, I would have to fork it using & and $? would not work.
Does anybody know why faucet isn't responding correctly in this particular case and/or can suggest a solution to this problem. I am not married neither to faucet nor netcat but would like the solution to be implemented using bash or it's utilities (as opposed to write something in yet another scripting language, such as Perl or Python).
I'm dying to know how I can make a GUI for ffmpeg and jhead in OSX. I've been looking for a solutionfor a while and thought you, stackoverflow's users, could help me. Maybe you know some document I haven't come across of or, better, a tutorial to make a GUI.
I love those two tools but I like the simplicity of drag/drop operations.
Note: I don't need a GUI for them, I want to make one.
i start up an existing solution, click on a javascript file, the file opens up in the IDE for a few seconds and then visual studio disappears. This is consistent and reproducible.
I saw this patch for KB958502 and installed it but it didn't seem to do anything.
Any suggestions on how i can proceed as this is completely stopping my development here.
I have a team developing software in MS Visual Studio and now they want to start using MS Team Foundation Server, mainly for versioning and maybe patch and bug tracking.
They don't have any experience with MS Team Foundation Server, but they are very enthusiastic with MS products.
So whats the best free open source alternative solution? Git, SVN, CVS, Bugzilla, plugins, etc.
I'm starting a blog with a hosted wordpress instance and i would like to be able to stream music using a flash player on some posts.
The problem is that every player i find uses a simple param to get the file url which makes it very easy for someone to find that url and just download the file.
A server side solution can be implemented as i have full access to the server.
I usually do this in Perl:
whatever.pl
while(<>) {
#do whatever;
}
then cat foo.txt | whatever.pl
Now, I want to do this in Python. I tried sys.stdin but I have no idea how to do as I have done in Perl. How can I read the input?
Thanks.
EDIT:
Thanks, I like every single solution.
Hi,
I new in database design:
I have question with my own few solution,what do you thinks?:
Which tables should be created for all kinds files (images, attached email files,text files for store email body, etc..) that stored in my online store?
*option 1:use seperate table for files types *
files{
id
files_types_id FK
file_path
file_extension
}
files_types{
id
type_name (unique)
}
*option 2: use bool field for each file type *
files{
id
file_path
file_extension
is_image_main
is_image_icon
is_image_logo
is_pdf_file
is_text_file
}
**option 3: use 1 enum field 'file_type' for each file type **
files{
id
file_path
file_extension
file_type (image_main,image_icon,image_logo,image_main,pdf,text) **enum**
}
Thanks you,
Yosef
My client have created a script in php+mysql that saves images directly in the database and every images has url like this: www.example.com/image.php?id=421
In your opinion this is a very wrong solution ? Should I rebuild all the site ?
There are about 1000 visits per day and about 600 images in the database.
This is the site: http://tinyurl.com/3xkxdsw
I'm using LinqToSql like this with a CheckBoxList in ASP.NET:
var teachers = from x in dc.teachers select x;
cbl.DataSource = teachers;
cbl.DataTextField = "name";
cbl.DataValueField = "teacherID";
cbl.DataBind();
I want to display both "firstname" and "name" in the DataTextField however.
I found this solution but I'm using LINQ:
http://stackoverflow.com/questions/839223/concatenate-two-fields-in-a-dropdown
How do I do this?
Ever since I started programming this has been something I have been curious about. But seems too complicated for me to even attempt.
I'd love to see a solution.
1, 2, 3, 4, 5 // returns 6 (n + 1)
10, 20, 30, 40, 50 //returns 60 (n + 10)
10, 17, 31, 59, 115 //returns 227 ((n * 2) - 3)
I'm looking for a way to determine if a file has been executed or not. I've looked a bit into FileInfo's LastAccessTime but this doesn't seem to change when a file is executed. I've also looked into FileSystemWatcher but this also doesn't seem to offer a solution. Is there such a thing as a file execution listener or is there another way? If it helps, i'm looking to write a folder listener that renames an .avi file within it after it has been watched/executed.
Hi All
I'm designing a Test.aspx page which give an overview regarding the status of several software : Windows service, Web application , Web service, Playout ...
I have already a FTP.cs class which implement edtFTPnet.dll logic.
I need just 3 things :
How test if a server has an FTP Server solution installed or not.
Check if FTP server is up or down
Check if the giving login and password are correct
Best regards
Not a technical question, but related to IT.
At the moment I work in the open plan office and the guy next to me is talking to himself
while programming. It annoys my collegue and me so much that we are putting the earphones on with music volume set to max.
Does anyone know good and polite solution to shut him up?
hi
I have a project with following sql table
companymaster expbill invcarat
companyId companyid companyId
name invno invno
address buyer srno
telno consignee qty
rate
amount
I have tried many times by the way of ADO.Dataset with multiple sql query but reports show like sticky problems. the details section repeating from diferent companyID and invno am tired don't know how to overcome from this kindly provide me better solution with good example.
I have a file whose size is about 300mb i want to read the contents line by line and then add it into arraylist. So i have made an object of array list a1 , then reading the file using bufferedreader , after that when i add the lines from file into arraylist it gives an error Exception in thread "main" java.lang.OutOfMemoryError: Java heap space. Please tell me what should be the solutionfor this.
I have an executable (no source) that I need to wrap, to make sure that it is not called more than once at a time. I immediately think of some sort of queue wrapper, but how do I actually make it so that my wrapper is called instead of the executable itself? Is there a better way to do this? The solution needs to be invisible because the users are other applications. Any information/recommendations are appreciated.
Let's say I want to make a little wrapper along the lines of:
def wrapper(f: (Any) => Any): Any = {
println("Executing now")
val res = f
println("Execution finished")
res
}
wrapper {
println("2")
}
Does this make sense? My wrapper method is obviously wrong, but I think the spirit of what I want to do is possible. Am I right in thinking so? If so, what's the solution? Thanks!
I'm looking for a jQuery solutionfor this. When I click, let's say on a artist name. Theirs another div beside that has the information showing up. (possibly in a animation/fading way)
Can anyone help?
I have a list of files named:
file000
file001
file002
file003
...
file1100
How can I match all files that have a number greater than 800 but less than 1000 ?
I am using linux bash
Thank you
Edit
Actually, my files are named like:
ab869.enc
cp936.enc
g122345.enc
x2022.enc
abc8859-14.enc
aax5601.enc
cp936-1.enc
so the first solution dont match the correct files :(
How can I match files that have number between 800-999 ?
I'm getting awful lot of spam to my forums where only registered users can post and captcha is in use. What could we best solution to stop spammers registering to my forums?
My table looks like this with duplicates in col1
col1, col2, col3, col4
1, 1, 0, a
1, 2, 1, a
1, 3, 1, a
2, 4, 1, b
3, 5, 0, c
I want to select distinct col1 with max (col3) and min(col2);
so result set will be:
col1, col2, col3, col4
1, 2, 1, a
2, 4, 1, b
3, 5, 0, c
I have a solution but looking for best ideas?