1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

what is alternative to vi on tomato?

Discussion in 'Tomato Firmware' started by samjones3, Jul 10, 2012.

  1. samjones3

    samjones3 Serious Server Member

  2. koitsu

    koitsu Network Guru Member

    Should have kept this in the existing thread, honestly.

    How big is the file you're trying to open in vi?

    Be aware the vi that comes with TomatoUSB is actually vi written by the Busybox people. It's utterly horrible.

    Alternately you could try using vim from the Entware project, but in my experiences vim tends to use more memory than classic vi. Of course, Busybox vi, like I said, is a pile of crap. You might have to use the -n flag to vim to get it to not use a swapfile (this is a different kind of swapfile from actual UNIX swap, e.g. swapon, so do not confuse the two).

    And if none of these things work for you, then good ol' fashioned ed might have to be used... except it isn't provided in Busybox and I can't find a build of it anywhere. You almost certainly wouldn't like the user interface (only us old UNIX admins seem to understand ed).

    Overall I wouldn't get too comfortable using the CLI in TomatoUSB for things like file editing, etc.. It's Linux, but you need to remember it's a bare-bones embedded environment. It's not the same environment/setup as, say, if you ran Linux on a desktop system.

    Otherwise you're going to need to get a router that has more RAM, or provide more insights to any sort of other adjustments you might have done to your TomatoUSB setup (that might explain lack of memory).
  3. waeking

    waeking Networkin' Nut Member

    you could install ipkg and then nano
  4. samjones3

    samjones3 Serious Server Member

    Hey, I am fine with ed
    I am fine with anything I can make work!!!

    I am concerned that the vi failure is actually some other problem. vi was working fine for me, but stopped at a certain point.
    I am concerned that the real problem is that the files are bad or I lack rights or something. I can cat the files fine, but cain't edit em... @#$@
  5. koitsu

    koitsu Network Guru Member

    I would love to see the exact error you get from the shell, rather than just "But if I specify vi <filename> I get the memory exhausted error ..."

    But sadly I don't have a way to figure out what's busted due to the lack of decent debugging tools under TomatoUSB given its design and lack of space due to being embedded. If you installed Entware (opkg + etc.) you might be able to get strace, which would greatly help in determining what syscall is being made that returns ENOMEM, and *how much* memory was being allocated.

    Please do not follow the advice of using ipkg + nano. The Optware (re: ipkg) repository contains outdated utilities; we're talking outdated by 4-5 years. Please consider using Entware (see the wl500g-repo link I provided in my previous post) instead. It's actively maintained and the author is *very* responsive. Here's an example:

    root@gw:/tmp/home/root# opkg list | grep strace
    strace - 4.5.20-1 - A useful diagnostic, instructional, and debugging tool. Allows you to track what
    root@gw:/tmp/home/root# opkg install strace
    Installing strace (4.5.20-1) to root...
    Downloading http://wl500g-repo.googlecode.com/svn/ipkg/openwrt/strace_4.5.20-1_entware.ipk.
    Configuring strace.
    It's also possible that your Busybox binary may be corrupted somehow (e.g. physical flash blocks have been worn out) and is therefore behaving oddly. This is not the same thing as filesystem corruption. But I would expect that other Busybox tools would be behaving badly too (but not necessarily). Remember: Busybox's mentality is to make a single fat/huge binary and then use symlinks to point to it (e.g. /bin/vi -> /bin/busybox), then parse argv[0] to find out what utility you called it by and invoke the correct code based on that. For example /bin/busybox on my system is 729224 bytes -- that means every single utility that's a Busybox symlink is going to take up 729KBytes of RSS/RES (shared memory would only apply to the libraries its linked to, which are libcrypt, libm, libgcc_s, libc, and ld-uClibc). You might expect vi to have a much smaller footprint than that, but it's not going to -- welcome to the flawed way Busybox was designed (it violates UNIX concept (multiple small and separate programs that can be used together)).

    I would start by trying something like re-flashing the entire firmware, then do a full NVRAM erase ("thorough erase") as well. Then, once things are up, and BEFORE doing any changes in the GUI, telnet in and see if vi still behaves that way.
  6. samjones3

    samjones3 Serious Server Member

    Wow, thanks for the nice write up!

    You gave me enough to get started with. When I get home tonight I will start digging.

    Reflashing and dumping optware is certainly an option! I was just following http://tomatousb.org/tut:how-to-set-up-nas-optware-etc-for-total-noobs
    I will try to see where vi is executing from, as I wonder if optware or such gave me a 2nd vi or messed with busybox.
  7. ulyan

    ulyan Networkin' Nut Member

    samjones3 you might be interested in entware. Way better than optware -> https://code.google.com/p/wl500g-repo/wiki/Using. Some user in the forum recomended it to me and I didn't look back since then :D

    And yes, I too recommend nano. Way easier to use and navigate, search etc.
  8. mvsgeek

    mvsgeek Addicted to LI Member

    ftp ---> notepad ---> dos2unix ---> ftp
  9. ryzhov_al

    ryzhov_al Networkin' Nut Member

    Offtopic: Oh, sounds like a music^)) Thank you, guys.

    I'm using only mc-edit from plain-old DOS days. Even for C code in my repo.
  10. rhester72

    rhester72 Network Guru Member

    In case you want ed/vi, they're on my site.


Share This Page