I made a program in C that is supposed to try a bunch of numbers on a url, like this:
example.com/cbc001 ...com/cbc002
The program runs throught from 000 to 999 and is supposed to add those numbers after the 3 letters in the url. I managed to get the program to run through all numbers, 000-999.
Now my problem is I have no idea how to open a website in C, and I don't really want to open it in a browser, what I just need is the program to try all those urls ".com/abc990" and then I want to check the source file of the webpage to search for a certain word.
How could I approach this?
Related
I'm handling a bat file basically to redirect a streaming media content to VLC, my goal is to pratically automate the whole following steps:
Open the program that bridges the video stream to VLC (DONE)
the program gives a list of available resolutions to use as below:
[cli][info] Found matching plugin ustreamtv for URL
blablabla.com/channel/test
Available streams: 480p+ (best), 480p+_alt_akamai,
480p+_alt_highwinds, mobile_240p (worst)
Now what i need to do is basically find a way to "scan" this information for numbers in order to automate the following string
"C:\Program Files (x86)\Livestreamer\livestreamer.exe"
ublablabla.com/channel/test %quality%"p+_alt_highwinds" > nul
%quality% is there only because I'm currently typing manually whatever resoloution comes out in "Available streams:" to complete the string.
Ther's any way i can filter this result like if there is a 3 digits number before p+_alt_highwinds and automatically complete the string?
I'm sorry if this question looks like a complete mess.
I have a long running code which outputs stuff every minute. I will be running it all night and will check results in the morning.
Is there a way to write all the Console stuff to an external text file. I do not want to modify the code, but just looking to direct all Console output to an external file. I am working in Eclipse. I tried the Run -> Run Configurations... -> Your Application -> Common tab -> File idea but the output is horrible - no line breaks.
Is there a way to get the exact same output as the Console into a text file - all formatted nicely?
Many thanks in advance.
RS
you can add a text file. If you write your code to a file which is in a specific directory or if you know the name of it, your program can recognize this. For example, if your variable is words, you can write words = open("what your file is called") then at the end of you code end by writing to file: file.write(string)
I want to write the array cloud which is nothing abut a array storing the coordinates of a circular cloud with two columns, of latitude and longitude. I want these coordinates to be written on a text file in a manner like this.
418.9517 43.9866
419.2260 44.1501
419.4826 44.3402
419.7190 44.5550
419.9327 44.7923
420.1217 45.0497
With this code i want to generate multiple no of such files storing the coordinates of a single cloud in one file.
Here a is array with first two columns of latitude and longitude (center of circle) and the third one radius of the circle. And z =size(a).(which is 2905x3). So that makes a total of 2905 files to be written.
for s =1:z(1)
r= a(s,3);
ang=0:0.1:2*pi;
xp=a(s,1) + r*cos(ang);
yp=a(s,2) + r*sin(ang);
xp=xp';
yp= yp';
cloud = [xp,yp]
filename = ['Shower_Cloud',s,'number.txt']
file_id = fopen (filename,'w');
fprintf(file_id,'%g\t',cloud[]);
fclose(file_id);
end
The error when i run the code is the main problem i'm not able to diagnose this problem on my own, although i have a feeling its a minor one.
>> xyz
D:\Users\Vikram\Documents\MATLAB\Manuela\Version_2\Weather\Shower\xyz.m:
Too many files open; check that FILES = 20 in
your CONFIG.SYS file.
Unexpected error status flag encountered. Resetting to proper state.
Please ask if i missed on something important to mention.
This is just a guess but one could expect strange behavior when concatenating numbers with strings.
You may want to use num2str(s) in creating the file name.
Maybe other parts of your program lose track of opened files. Use fopen('all') to list filehandles of open files. This is maybe a starting point for hunting down the bug.
Most likely is that some bug at some point in your code caused many files to be opened without being closed. Note that even though the code you posted does indeed close every file correctly, if you are still running the same MATLAB session you may still have files open.
You can close all currently open files like so:
fclose all
So I suggest you type that into the MATLAB prompt first. If you are still having the error, having a look at:
fopen all
which lists all currently open files; hopefully this will give you enough information to find the problem.
I have to do a simple text editor using the c language. But I don't know how to get started. The program should begin with a blank screen, waiting for the user to write something. The user is also able to move the cursor using the arrow keys and the user is also able to load text files to the program from his hard drive and also make a text file of something the user has written in the program.
He can load something by pressing CTRL-O or he can press CTRL-S to save something followed by the name of the text file.
Our professor said that we have to use the library screenUtils to make the cursor move.
How should I start? I'm trying to make this work for 3 hours but nothing really works.
Our professor said that we have to use the library screenUtils to make the cursor move. How should I start?
I would start by reading the documentation for this library.
I have the following simulation in C for cars in a traffic circle
alt text http://dl.getdropbox.com/u/175564/cars.png
For example,
7 <space> <enter>
gives more cars to the simulation, while
s1 <enter>
puts a top sign to the incoming road #1.
I want to put the simulation to an internet page such that users can try it.
However, I do not know where I should start.
I know Joomla and little about Django. Perhaps, they can be useful.
How can you put a C program to a Webpage such that users can use it?
CGI is what you want; it will let you embed any program you want into a website, it was made for that purpose. Then perhaps embedding a few more options with PHP and HTML will let the user acutally input data into the program via the web. It should not be too hard.
Take a look here for more info: http://www.cs.tut.fi/~jkorpela/perl/cgi.html
I think that is a good pointer in the right direction. I hope that helps.
You could run the C code in a flash app using alchemy:
http://labs.adobe.com/technologies/alchemy/
Here's a good intro to writing CGIs in C: http://www.cs.tut.fi/~jkorpela/forms/cgic.html
However, since you're a beginner, I'd recommend porting your program to PHP. It's a very easy language to pick up, and it's a much easier route than writing a CGI in C.
I assume the C program needs input while it's running and not via command-line arguments? If I'm wrong, you can just use PHP and shell_exec() to run the program. The function returns anything printed to stdout.
Such a page might look like:
$sim = shell_exec("/path/to/binary -a 5 -b 6");
echo $sim;
Where the string passed to shell_exec is exactly what you'd type on the command line.
If you want a dynamic simulation, where the cars moves while you watch , you'll need an applet or flash.
A cgi program renders the page on each http GET/POST (on reload, submit etc)
and that is probably not what you want.
I would start with a flash or java applet wrapper. You can communicate with your application over a tcp connection and display the results in the flash or applet.
I would recommend going with sockets. If your C program could set up and listen on a local or internet socket, you could use the socket facilities in any language to send it arguments and get output.
If that's going to be too much of a pain, have php exec the program while directing the output to some file. Then, have php read that file.
Looking at the output of your program, I think trying to print the results of shell_exec() will result in clobbered output.
So, you could shell_exec("/bin/program -arguments > /tmp/prog-tmp.txt") , then read prog-tmp.txt.