Sign in to follow this  
Followers 0
andrew545

File question

21 posts in this topic

Hi, i'm trying to make a script wich takes the public ip address and writes it to a file when i write ip.txt

it goes to the desktop how do i make it save the file somewhere else

using filewrite()

Share this post


Link to post
Share on other sites



I'm making a script that takes a txt file and writes the pubic ip address to the file

but when it writes the file it saves it to the desktop how do i make it save it somewhere else like c: ?

answers wil be appreciated

Share this post


Link to post
Share on other sites

Please help, I'm writing a script that takes an ipaddress and writes it to a text file and it ends up on the desktop, how do i write the file somewhere else like C: ?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

You aren't making a great start here in our forums.

I have removed this question from a totally unrelated thread and merged the other 3 created topics.

Please stick to a single thread/post when you have a question.

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Change the path you're using to the path you want.

depending on OS you might need to add #RequireAdmin directive.

 

I'm using windows 8

Share this post


Link to post
Share on other sites

Local $Publicip = _GetIP()
Local $File = FileOpen($Publicip, 1)
FileWrite("ip.txt", $Publicip)
FileClose($File)

Share this post


Link to post
Share on other sites

You also need to study the FileOpen/Filewrite/FileClose in the helpfile as you are mixing things up... should be something like:

Local $Publicip = _GetIP()
Local $File = FileOpen("ip.txt", 1)
FileWrite($File, $Publicip)
FileClose($File)

 

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

So, now How do i save ip.txt to a different location rather then the desktop because when i run the script that is where it gets saved to

Share this post


Link to post
Share on other sites

So, now How do i save ip.txt to a different location rather then the desktop because when i run the script that is where it gets saved to

Specify the correct target directory in the script .. maybe?

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

ok, i have looked through the documentation on filewrite and _FileWriteLog but nothing explains how i would save the file in a different location

and it is aggervating me

Share this post


Link to post
Share on other sites

Seriously?

Change your filename to a full path and filename.

If you do not understand what a path is I'd have to wonder what business you have at the flesh end of a keyboard, let alone scripting.

Use web search to learn basic computing first would be your best bet.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
OK, i have done that but i had a script that saved it to c: but then i deleted and i have looked through the documentation and im stuck that's why im asking for help smart ass

Share this post


Link to post
Share on other sites

shouldn't it be filewrite("ip.txt", @WindowsDir, 1)

?

Share this post


Link to post
Share on other sites

How about @WindowsDir & "ip.txt" ?  The way you wrote it won't work, as FileWrite only takes 2 parameters, you gave it 3. Even if it had worked, all it would do is write the text of the macro @WindowsDir (Usually C:Windows) to the text file.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

I have tried both of those filewrite("C:" "ip.txt")

well could someone test it and see if they can get ip.txt to the C: directory rather then the desktop ?

Here is the code

#include <Inet.au3>
$PublicIP = _GetIP()
FileOpen("ip.txt", 1)
FileRead($PublicIP, 1)
FileWrite("ip.txt", $PublicIP)

and run it and you'll see what i mean it will end up on the desktop

and i dont want it there sorry if this is an inconvenience but im very annoyed at this point and would

just like to get it saved to c:

oh and this is going to be a remote administration tool by the way in case any of you were wondering.

Edited by andrew545

Share this post


Link to post
Share on other sites

Why are you creating 2 literal strings in stead of 1?

Just add c: in front of the filename inside of the "".

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

and i dont want it there sorry if this is an inconvenience but im very annoyed at this point and would

just like to get it saved to c:

oh and this is going to be a remote administration tool by the way in case any of you were wondering.

 

You keep complaining about how annoyed you are, or how "aggervating" (your horrible spelling, not mine) this is for you. Yet you aren't listening to the help people are trying to provide to you. First off, since you are on Windows 8 and you're trying to save to the root of C:, you need to ensure #RequireAdmin is at the top of your script.

Secondly, this:

FileRead($PublicIP, 1)

..makes no sense at all. Go back and look at the first parameter for FileRead, to see the mistake. 

Lastly, as has been suggested several times, try a literal path for the file.

#RequireAdmin
#include <Inet.au3>

$PublicIP = _GetIP()
FileOpen("C:\ip.txt", 1)
;>>>>FileRead($PublicIP, 1) ***Get rid of this, it makes no sense***
FileWrite("C:\ip.txt", $PublicIP)

...this works just fine on WIN8


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0