It seems that you're using an outdated browser. Some things may not work as they should (or don't work at all).
We suggest you upgrade newer and better browser like: Chrome, Firefox, Internet Explorer or Opera

×
Hi,

I have been working on a script that creates a specific string, I got it working fine, but is there a way to make it save the string to a .txt file in a specific directory?

I have worked with batch programming for a while now, so I know more than just the basics, but this is something I do not know;

So, is the GoG community going to amaze me with it's knowlege once again?

Thanks,

sloganvirst
This question / problem has been solved by Miaghstirimage
Are we talking .bat as in what's essentially basic or something more linux oriented?

With a .sh you could just echo the string and redirect it to an empty file.
echo $string >> /path/to/file/file.txt
echo %stringvariable%>c:\path\to\file.txt

or, if you want to keep whatever's in the file, and just append the string to the end, replace > with >>
avatar
hedwards: Are we talking .bat as in what's essentially basic or something more linux oriented?

With a .sh you could just echo the string and redirect it to an empty file.
echo $string >> /path/to/file/file.txt
Not sure quite what you mean...

I am using Windows XP, I created a .txt file, wrote my script in it, renamed it to a .bat file.
It works fine, I just wanted it to save it's product to a .txt file.


EDIT:
avatar
Miaghstir: snip
Thanks! +rep for you!
avatar
hedwards: snip
Sorry, Miaghstir beat you to it. Thank you anyway! I up rated your post though...
Post edited November 13, 2011 by sloganvirst
avatar
hedwards: snip
avatar
sloganvirst: Sorry, Miaghstir beat you to it. Thank you anyway! I up rated your post though...
Not a problem, it makes a significant amount of difference how one does this depending upon platform. Windows does it as Miaghstir puts it and pretty much everybody else does it the way I listed.
avatar
hedwards: Not a problem, it makes a significant amount of difference how one does this depending upon platform. Windows does it as Miaghstir puts it and pretty much everybody else does it the way I listed.
Not that there's much of a difference in usage for this quite basic example. $varname or %varname%

Of course, there is more difference behind the scenes. For example, the *nix shell variable is local to that script, while the Windows batch variable is local to the cmd.exe instance it's running in and available to anything lauched from it.
avatar
sloganvirst: Sorry, Miaghstir beat you to it. Thank you anyway! I up rated your post though...
avatar
hedwards: Not a problem, it makes a significant amount of difference how one does this depending upon platform. Windows does it as Miaghstir puts it and pretty much everybody else does it the way I listed.
Ah, I haven't got any Unix based OS's yet, though I was considering Linux as a start, so I havn't really done much more than Batch and stuff like that.
avatar
Miaghstir: Not that there's much of a difference in usage for this quite basic example. $varname or %varname%

Of course, there is more difference behind the scenes. For example, the *nix shell variable is local to that script, while the Windows batch variable is local to the cmd.exe instance it's running in and available to anything lauched from it.
Oh, I didn't know it did that!, though, I have only seen Linux on an old computer I used once or twice.
avatar
hedwards: Not a problem, it makes a significant amount of difference how one does this depending upon platform. Windows does it as Miaghstir puts it and pretty much everybody else does it the way I listed.
avatar
Miaghstir: Not that there's much of a difference in usage for this quite basic example. $varname or %varname%

Of course, there is more difference behind the scenes. For example, the *nix shell variable is local to that script, while the Windows batch variable is local to the cmd.exe instance it's running in and available to anything lauched from it.
Right, but it is a bit of a difference. Personally, I prefer to script from a *nix shell just because there's a lot more you can do without having to count on anybody to foresee the need. It's awesome some times to combine sed and awk and get something really funky that nobody's thought about doing before.