As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/
Options

Using 'cp' in OS X Terminal

HallucinogenHallucinogen Registered User regular
So I've been trying to copy some files to my tftp folder with the Terminal, but I can't seem to get it to work.

What I entered was:

cp filename.txt ~/private/tftpboot

But I get:

cp: /Users/username/private/tftpboot: No such file or directory."

So I assumed this was because I was in my user folder, rather than at the root directory where /private/tftpboot is located.

I'm sure there's a way to set yourself at the root directory of the system but I can't remember, or find on the internet, how.

Or is there another way I should be doing it?

[SIGPIC][/SIGPIC]
Hallucinogen on

Posts

  • Options
    GoofballGoofball Registered User regular
    edited July 2009
    Don't put the ~ at the start of the path on /private/tftpboot - The tilde (~) in FreeBSD which is what OSX/Darwin is built on, is shorthand for "current user directory".

    "cd /" will change you to the root directory. "cd /blah" will put you in the /blah directory, etc.

    Goofball on
    Twitter: @TheGoofball
  • Options
    theSquidtheSquid Sydney, AustraliaRegistered User regular
    edited July 2009
    ~ is shorthand for "your home directory"
    Try
    cp filename.txt ~root/private/tftpboot/
    

    Of course, you probably won't be able to copy something into a root directory since you won't have the permissions for it, so you'd have to become root.

    I'm a Linux user, not a Mac user, so I'm not sure how you'd do it... try
    su
    
    ?

    EDIT: Wait, durh, root directory, not root user's home directory...
    cp filename.txt /private/tftpboot/
    
    You may have to become root anyway.

    theSquid on
  • Options
    LindenLinden Registered User regular
    edited July 2009
    As a more general note, if you do need root permissions, using sudo rather than su is probably a good idea for most things. su is also, from memory, not directly accessible by default, as the root user is disabled. That said, sudo su will work quite happily - su doesn't request a password if run by root.

    Linden on
  • Options
    HallucinogenHallucinogen Registered User regular
    edited July 2009
    Thanks for the help, guys. After logging in as root using sudo su I tried:

    cp filename.txt /private/tftpboot

    ...and I didn't get a directory error, but I also didn't receive any confirmation, either. Am I supposed to get any sort of 'success' or 'bytes transferred' response? Also, how do I delete the files I place in /private/tftpboot in the Terminal, so I don't have to resort to revealing hidden files/directories.


    I have a couple of other question regarding flashing my Asus 520gu with Tomato. It's not so simple on a Mac as it was with my WRT54GL, and I've run into a multitude of methods with which to do it.

    Tomato's Windows cmd instructions list(there weren't any for OSX that didn't involve Parallels):

    tftp -i 192.168.1.1 put tomato-ND.trx

    But I think using OS X's terminal I would need to use -e rather than -i after reading Apple's Man pages for tftp.

    DD-WRT's instructions for OS X:

    tftp 192.168.1.1
    > binary
    > rexmt 1
    > timeout 60
    > put tomato-ND.trx


    This one uses a timed retry to make sure the firmware gets through during the router's reset, but also uses 'binary' rather than -i or -e. Does it matter whether I use -e or 'binary'?

    One more I've found on the Apple discussion boards:

    man tftp
    tftp -e 192.168.1.1
    put tomato-ND.trx
    quit


    Which is the same again, but uses -e for the binary transfer option.

    I'm think for best results I should use:

    tftp -e 192.168.1.1
    > rexmt 1
    > timeout 60
    > put tomato-ND.trx

    Hallucinogen on
    [SIGPIC][/SIGPIC]
  • Options
    InfidelInfidel Heretic Registered User regular
    edited July 2009
    ...and I didn't get a directory error, but I also didn't receive any confirmation, either. Am I supposed to get any sort of 'success' or 'bytes transferred' response?

    Most core command line utilities (and many others) follow the philosophy of "Do, or do not. There is no try." It either succeeds or fails. It prints an error on any failure, so lack of error = success!
    Also, how do I delete the files I place in /private/tftpboot in the Terminal, so I don't have to resort to revealing hidden files/directories.

    The rm command for "remove" but be careful with that one, obviously. :lol:

    Some other commands you may need, are cd for "change directory" and ls for "list", you could do something like this:

    > cd /private/tftpboot
    > ls
    filename.txt
    > rm filename.txt

    Infidel on
    OrokosPA.png
  • Options
    BarrakkethBarrakketh Registered User regular
    edited July 2009
    Infidel wrote: »
    ...and I didn't get a directory error, but I also didn't receive any confirmation, either. Am I supposed to get any sort of 'success' or 'bytes transferred' response?

    Most core command line utilities (and many others) follow the philosophy of "Do, or do not. There is no try." It either succeeds or fails. It prints an error on any failure, so lack of error = success!

    That said, if you add the -v argument it'll be chatty about what it's doing.

    Barrakketh on
    Rollers are red, chargers are blue....omae wa mou shindeiru
  • Options
    HallucinogenHallucinogen Registered User regular
    edited July 2009
    So, cp -v filename.txt /private/tftpboot?

    I take it you can use the verbose option for most/all commands, then?

    Edit: I listed the contents of the tftpboot folder and the file is there. Thanks Infidel. It occurred to me to use ls to check the contents, but I forgot about using cd to get to the folder so the command would work.

    I need to use the Terminal more often so I can remember things like that. Maybe when the WL520gu inevitably dies I'll get better with Linux/Unix as I build my own router with Smoothwall or something similar.

    Hallucinogen on
    [SIGPIC][/SIGPIC]
  • Options
    InfidelInfidel Heretic Registered User regular
    edited July 2009
    So, cp -v filename.txt /private/tftpboot?

    I take it you can use the verbose option for most/all commands, then?

    If it has one, and it's not always -v

    Here's a command you should be using asap: man

    Try it.

    man cp

    man rm

    man grep

    etc.

    Infidel on
    OrokosPA.png
  • Options
    iTunesIsEviliTunesIsEvil Cornfield? Cornfield.Registered User regular
    edited July 2009
    Infidel wrote: »
    So, cp -v filename.txt /private/tftpboot?

    I take it you can use the verbose option for most/all commands, then?

    If it has one, and it's not always -v

    Here's a command you should be using asap: man

    Try it.

    man cp

    man rm

    man grep

    etc.
    This may possibly be the most polite "RTFM" I've ever seen.

    iTunesIsEvil on
  • Options
    InfidelInfidel Heretic Registered User regular
    edited July 2009
    This may possibly be the most polite "RTFM" I've ever seen.

    ... wow, so true. :lol:

    Infidel on
    OrokosPA.png
  • Options
    LindenLinden Registered User regular
    edited July 2009
    Also, because it's not discoverable, hit q to exit man. Otherwise, ctrl-c is a useful combination. Never run ed if you can avoid it.

    Linden on
  • Options
    HallucinogenHallucinogen Registered User regular
    edited July 2009
    So that's what man does... hah. Thanks. I'll try to avoid asking any more basic questions from here on.

    If this a basic/dumb question, I apologize, but I couldn't find an answer in the man pages or on the internet. Should I be using -e, binary, or neither when sending the firmware to the router? Of the instructions I listed above, one uses -e, another uses binary, and one don't use either.

    Hallucinogen on
    [SIGPIC][/SIGPIC]
Sign In or Register to comment.