0

I need to change somehow size of files (increase or decrease) on Windows machine using bash scripts. (Content of files doesnt matter) But i have to run this scripts from remote linux machine. I've selected truncate command for size changing, this is exactly that i need, cause i need to change size exactly of chosen file, without changing it's descriptor. It is very important.

But i DO NOT have truncate on my linux machine and i CANNOT install it there (So dont tell me to install it there plz :)). I cannot install nothing on my linux machine it has specific kernel - this is a main option of all my problems.

So i've decided to install cygwin on my Windows machine, cause it has truncate command. Also i know that there are fallocate command, but my linux machine also doesnt have it, and cygwin doesnt have it too. So if there is some another command i wanna know it :)

Then after this steps i tried to change file size from cygwin terminal via truncate and all works perfectly. And the last problem that i had to solve was just run cygwin's bash from my remote linux, i've chosen winexe for that.

Finally the way that i've chosen is:

I run winexe command on my linux machine that runs:

 winexe myHost "c:\cygwin\bin\bash.exe myScriptWithTRUNCATE"

on my Win machine.

But it doesnt work and i dunno why. truncate command doesnt change size of files at all. When i type

 truncate --help

all works, i can see result of help option on my linux terminal, but e.g.

truncate -s someSize myFile

doesnt work, size of file doesnt change. Also error code from truncate -s someSize myFile is 0

Any suggestions?

Bohdan Sukhov
  • 212
  • 2
  • 5
  • I'm not understanding where you're hitting issues. When you run `truncate -s ` in a Cygwin bash terminal on your Windows machine, does that work or not? – me_and Jul 02 '12 at 11:33

1 Answers1

0

try giving the name of your script that is "myScriptWithTRUNCATE" directly in winexe command . example:- winexe myHost "c:\cygwin\bin\bash.exe myScriptWithTRUNCATE" also check debug log of winexe by modifying winexe command as :-

winexe -d 5 myHost "c:\cygwin\bin\bash.exe myScriptWithTRUNCATE"

see in this log what actually is sent over to windows as command in place for your script. specifically see in " CTRL: sending command : run xxxxx" see what "xxxxx" is in that debug log.

winexe gives you the control of windows command line(cmd.exe). Try running you script after it has got control of cmd.exe.

Based on some findings above , try this link for more help http://blog.dotsmart.net/2011/01/27/executing-cygwin-bash-scripts-on-windows/

Akshay Patil
  • 954
  • 1
  • 12
  • 28