Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
Experts
I'm trying to send two files in a single sftp command line. right at the moment, I can only send 1 file when using the command line.
sftp host file1
but I'm looking for
sftp host file1 file2
I have to do that on 4 differents servers every day with different username.
Thanks
If you know what files exactly you want to send, you should use the scp utility. It can do just what you want.
scp file1 file2 .... user#host:/path/to/folder
Thanks to Neil for remembering the ":/path/to/folder" bit
To do it with different usernames you could probably script it. Something along the lines of:
#!/bin/bash
scp "$#" user1#host
scp "$#" user2#host
scp "$#" user3#host
scp "$#" user4#host
usage: ./myscript.sh file1 file2 ... filen
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I'm trying to enter input without typing anything I'm trying to put the input in the command.
I've seen people try this:
printf 'argument\n' | command
Or
command <<< "argument\n"
I don't know if what I'm doing is command specific but neither of these work for what I'm trying to do.
I'm trying to zip a file with a password:
zip -r -e test.zip test_zip/
-e is for password input (this isn't the part I was talking). I set the password to test1234.
When I unzip the file I try things like this:
printf 'test1234\n' | unzip test.zip
But it still asks for password input.
Any suggestions?
If you are using the Linux command line, try using echo.
echo 'test1234' | unzip test.zip
Use the -P argument
unzip -P <password> <zipfile>
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
So I have an assignment in linux terminal asking me to create a file in the home directory and to make the file display all the commands of the bash shell which is found in the /bin directory.
I already tried to use the echo command to display the commands to the file but it is not working:
echo $ls /bin > File1
I expect that the file contains all the commands of the bash shell, but when I type the line above in the linux terminal, the content of the file is just the word "/bin".
Is there any other way to use to meet the expected result?
Here you don't need the echo command, as ls already prints to standard output, which can then be piped to the file. The command you want is:
ls /bin > File1
A good way to go about this is by checking that "ls /bin" by itself will print to standard output the contents of /bin, and once you see the expected output, run it again with the "> File1" to then output to File1.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I have the following username#machine connection
user1#machine1 -> user2#machine2
How can I copy files from machine2 to machine1?
You can use rsync
Use it like this:
rsync -avz -e ssh remoteuser#remotehost:/remote/dir /this/dir/
Here is step by step tutorial. You can read about differences between rsync and scp here
You can use scp
Use it like this
scp <source path> <destination path>
Where the remote file is addressed as user_name#host_name:path/to/file
Suppose you want to get a file named a.txt which is in the home directory of user user2 on machine2 say, 192.168.1.10. You can do this on your machine1,
scp user2#192.168.1.10:a.txt .
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I have many files named xxxx.min.js and want to rename the files to xxxx.js so basically want to remove .min only.
Is there a command I can use to do this job?
I thought using rename command would be easy for each single file, but that would take forever since I have many of them.
any idea?
Here's a bash-only command (not requiring Perl)
for i in *.min.js; do a=$(basename $i .min.js); echo mv $i $a.js; done
Explanation
for i in *.min.js; do
loop over all files matching *.min.js
a=$(basename $i .min.js)
extract the base name of the file (i.e. strip off .min.js) and save the result in $a
echo mv $i $a.js
for now, print to the console the command that WOULD be run if you removed the echo
When you are satisfied that it generates the correct commands, remove the echo to actually rename the files.
Ubuntu and Debian linux distribution both have a perl version of mv function called rename or prename, which supports regexp. The manual can be found here.
Go to the folder of the files and run the command as follows:
rename s/\.min\.js$/\.js/ *.min.js
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
in linux, we have lots of flags to list files in command ls. we can't do the same inside sftp commannd. For example, in linux, I can list a file's full time by runnling command:
ls --full-time filename
when I sftp to a server, I can't run command: ls --full-time.
The ls help in sftp doesn't list all available flags. So can you please tell me what are ls flags in sftp?
Thank you!
The ls command in sftp is an internal sftp command which is in no way related to the ls command of the remote system's core utilites.
sftp (which has a similar interface as ftp) provides it's internal commands to allow listing of files(among other commands), which does not invoke the ls of the core utilities. So do not expect the same behavior.
For more details on sftp's internal commands please refer to sftp manpage or this page