Page 1 of 3 123 LastLast
Results 1 to 10 of 27

Thread: IP saved to txt file

  1. #1
    Senior Member
    Join Date
    May 2004
    Posts
    206

    IP saved to txt file

    Does anyone know how you would make, using c++, basic, batch programming, or any language :-p, a program that would run a windows command in cmd.exe, and then save the output to a text file? Thanks for any help.
    It is better to die on your feet than to live on your knees.

  2. #2
    Banned
    Join Date
    Jul 2001
    Posts
    1,100
    Greetings:

    A simple 1 line batch file can do the trick:

    command > file.txt

    save it as Program.bat and execute =)

    note: it will replace file.txt each time it's run. if you'd rather it append the results to the file, instead of replacing it completely, use >> instead of >

  3. #3
    I'll just show a basic command line way here (for dos/win) that could also be placed in a batch file. What you need to do is use output redirection. Sounds difficult? well, it isn't.
    anycommand > data.txt (could be dir /a > files.txt)
    this type of redirection creates a file named "data.txt" and the output from "anycommand" would be written in that file. This method would delete any existing file named data.txt that is is the current directory.
    now, using anycommand >> data.txt (could be dir /a >> files.txt) is called "appending" because it adds "anycommand" 's output to the end of the file "data.txt".

    I think it also works this way in linux (at least using bash) but you have the ability to suck out the error messeges also (check out a linux/unix book for more information)

    For basic... well i know it works in qbasic... you could do the same by executing the shell function (check out qbasic's help file for more information)

    Enjoy
    You are so bored that you are reading my signature?

  4. #4
    Senior Member
    Join Date
    May 2004
    Posts
    206
    Thank you! :-D This is exactly what I was looking for.
    It is better to die on your feet than to live on your knees.

  5. #5
    Senior Member
    Join Date
    May 2004
    Posts
    206
    Hmmmmmm. Would there be anyway to sent the output of the text file or the text file itself to another computer running a telnet server that would bring up a command prompt when telnetted to?


    Edit: Also, Is there any way to turn a batch file into a .exe?
    It is better to die on your feet than to live on your knees.

  6. #6
    Senior Member nihil's Avatar
    Join Date
    Jul 2003
    Location
    United Kingdom: Bridlington
    Posts
    17,188
    Why would you want to do that?

    I am not particularly happy with the direction we are going here?............has even the "great JP" been suXsor3d?

    Thoughts?

  7. #7
    Senior Member wiskic10_4's Avatar
    Join Date
    Jan 2004
    Location
    Corpus Christi, TX
    Posts
    254
    I'm with Nihil on this one...
    Jared, let us know what you're trying to accomplish - your questions will be received much better. As for turning the batch file into an executable, well, that's simple...
    C:\>ren file.bat file.exe
    -Wiski C.
    My Corner of the Intarwebz: Jeremy Dean Online

  8. #8
    Senior Member
    Join Date
    May 2004
    Posts
    206
    I have a computer on my network in my basement with no monitor. lol. I can run files though by making a cd-rom with an autorun file that runs a batch or an exe, or I can carry one monitor back and forth, but that is a pain.

    Edit: When you rename a .bat file .exe and run it, it just outputs some messed up text.
    It is better to die on your feet than to live on your knees.

  9. #9
    AO übergeek phishphreek's Avatar
    Join Date
    Jan 2002
    Posts
    4,325
    Originally posted here by Jareds411
    I have a computer on my network in my basement with no monitor. lol. I can run files though by making a cd-rom with an autorun file that runs a batch or an exe, or I can carry one monitor back and forth, but that is a pain.

    Edit: When you rename a .bat file .exe and run it, it just outputs some messed up text.
    Its much easier to just use a remote desktop tool...

    Look into VNC.

    You'll save yourself a lot of time and trouble.

    You can't rename a .bat to a .exe and expect it to work.

    A .bat is just a batch file.

    A .exe is a binary file. When you compile source code... the output is a .exe (not all the time... but at least on windows using something like c or c++)
    Quitmzilla is a firefox extension that gives you stats on how long you have quit smoking, how much money you\'ve saved, how much you haven\'t smoked and recent milestones. Very helpful for people who quit smoking and used to smoke at their computers... Helps out with the urges.

  10. #10
    Senior Member
    Join Date
    May 2004
    Posts
    206
    Originally posted here by phishphreek80
    You can't rename a .bat to a .exe and expect it to work.

    A .bat is just a batch file.

    A .exe is a binary file. When you compile source code... the output is a .exe (not all the time... but at least on windows using something like c or c++) [/B]
    I know that, but I was replying to wiskic10_4 who told me that when I asked earlier if there was any way to convert a batch file to an exe.
    It is better to die on your feet than to live on your knees.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •