Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How can I perform the following in one command? If not one, what about two?
Code:
# Currently logged on server 999.999.999.999
/path/to/command 1234 > /path/to/file
scp /path/to/file username@111.111.111.111:/path/to/destination
rm /path/to/file
Same question, but if logged on to 999.999.999.999 instead of 111.111.111.111
i copied the command from a script where i want to append to a textfile.
Hence the >> instead of a >
(in short: a typo. sorry :-).
And yes, i guess you gave the general summary of it (the quotes around " cat > filename" do matter, if i recall correct).
ssh command
only executes the command remote, after that you are still local (in case that was a question)
Not sure about the other question, user is logged in remote, i guess it doesn't matter.
> writes to the file if something is already there is gets written over will the new stuff.
>> appends whatever is being sent to what is already there.
using >> on first write will still get a file written, just the next time you will not have to change the > to >> if you are keeping a log type file, it saves recoding.
Using nodir example with a little change to path to directory first.
but as his name suggest he has no directory so maybe that is why he did not included a path to a directory in his example. (just playing off of your user name nodir. Nothing personal)
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233
Rep:
that would work, the question I have is, do you have root access to these machines? If so could you use an NFS share? or fuse SSHFS to mount the remote directory locally and then just read/write the file/directory as if it were local? Just a thought.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.