Progress bar in scp command

1

Unfortunately, scp doesn't display progress if stdout is not a terminal.

You have 2 options:

Option 1 modify scp code to ignore the stdout not being a terminal. Download sources (from http://www.openssh.com/)

Comment the following code in scp.c:main()

if (!isatty(STDOUT_FILENO)) showprogress = 0;

Option 2 Using a wrapper, fool scp to think that there is a terminal.

#include #include #include main(int argc, char **argv) { int fd; pid_t pid; char c,c1,c2; if (argc != 3) { printf("usage: [[user@]host1:]file1 [[user@]host2:]file2\n\nThis is a program that wraps scp and prints out the numeric progress on separate lines.\n"); fflush(stdout); _exit(1); } pid = forkpty (&fd, NULL, NULL, NULL); if (pid == 0) { execlp ("scp", "scp", argv[1], argv[2], (char *) NULL); _exit (1); } else if (pid == -1) { return 1; } else { FILE *F; F = fdopen (fd, "r"); //reading character by character isn't horribly efficient... while((c = fgetc(F)) != -1) { if (c...
0 0
2

Overview :

This tutorial will help the system administrators to know how to securely copy files to remote linux servers from local linux machine & vice versa in UNIX like operating system. SCP stands for Secure Copy ,it copies files between hosts over a network. It uses ssh for data transfer & uses the same authentication and provides the same security as ssh. Unlike rcp, scp will ask for passwords or passphrases if they are needed for authentication.

Below is the Syntax of copying File from Local Machine To Remote Machine

# scp examplefile username@Remote-Server:/home/

Above command will copy examplefile to remote under /home folder , it will ask the password of username mentioned in the command.

Syntax for Copying files from remote server to your local Machine

# scp username@Remote-Server:/home/examplefile /home

Above command will copy examplefile from remote Server’s /home folder to local machine’s home folder.

Some of the commonly used...

0 0
3

SCP: SCP stands for Secure Copy. SCP is used to copy data from one unix/linux sserver to another unix/linux server. SCP uses ssh(secured shell) to transfer the data between the remote hosts.

Features of SCP are:

Copies files within the same machine. Copies files from local machine to remote machine Copies files from remote machine to local machine Copies files between two different remote servers

Syntax:

scp [options] [userfrom_host:source_file] [user to_Host:Destionation_File]

Options:


Examples

1. Copy File from local host to remote host:

$scp filename root@serverk2.k2schools.com:/root

2. Copy File from remote host to local host:

$scp root@serverk2.k2schools.com:/root/dump*

3. Copy a directory

$scp -r directory root@serverk2.k2schools.com:/root

4. Specifying the port number.

$scp -p 6002 filename root@serverk2.k2schools.com:/root

Improve the performance of scp command: Using...

0 0
4
Oct 31, 2010

I would really like to capture the output of scp and my file's progress. Scp updates the transfer rate every 1 second, and I will like to save the transfer rate at every update. So for example, if the file transfer takes 30 seconds, I would like 30 reports of the transfer rate.

The output looks like:
Code:
file.dat 1% 3664KB 938.5KB/s 05:48

Whenever I try a simple redirect like:
Code:
scp file.dat 192.168.1.100:~/ &> output
... it does not save the rate at every update, it only shows the final rate.

If I try using typescript by starting "script" ... it's the same deal.

Ubuntu :: Capture And Redirect The Output Using Bash? Programming :: Bash Ambiguous Redirect - Redirect One Command Output Which Will Be Treat As A Content Of File For Another Command? Programming :: Bash: Capture All Output To A Log? Programming :: How To Redirect ALL Output To (log) File? Programming :: Redirect Output To Files Using Shell? ...
0 0
5

The in-game console can be opened with the F3 key. Laptops with a Fn key may have to use the Fn + F3 keystroke. Alt + F3 is also a solution. Commands may be entered into the console in the format followed by the return or enter key, where multiple parameters are separated by a space.

Note that the parameter of a command is not checked, so it may cause errors when used.

help String If 'string' equals "1", displays a list of commands that can be used. If 'string' equals "2", displays the second part of the command list. If 'string' equals another command, displays help for that command if it's available. 096state None Prints SCP-096's position, idle Boolean, and state if it has spawned. reset096 None Resets SCP-096 back its idle, sitting down state. 106speed Float Sets SCP-106's movement speed. Default is 1. 106state None Prints SCP-106's position, idle Boolean, and state. enable106 None Enables SCP-106 if it's either been disabled or contained. disable106 None Disables...
0 0
6

The in-game console can be opened with the F3 key. Laptops with a Fn key may have to use the Fn + F3 keystroke. Commands may be entered into the console in the format followed by the return or enter key, where multiple parameters are separated by a space.

Note that the command is not checked, so it may cause errors when used.

Command Parameters Description 096state None Shows SCP-096's position the true or false at the time and if it is in game. 106speed Speed:float Places SCP-106's movement speed to 'Speed' 106state None Shows SCP-106's position the true or false at the time and if it is in game. 173speed Speed:float Places SCP-173's movement speed to 'Speed' 173state None Shows SCP-173's position the true or false at the time and if it is in game. asd None Puts everything in lines, makes it so you cannot die, and makes it so you can float and go through walls. Also makes it kind of bright so you can at least see. brightness Brightness:integer Places how bright it is...
0 0
7
SCP

Introduction

Utility scp is a part of SSH suit allows files to be copied between machines. It is an updated version of an older utility named rcp, which is a part of rsh package initially developed by Sun, which in turn was based on BSD source code from the Regents of the University of California.

It works the same, except that information it transfers (including the password used to log in) is encrypted. Also, if you have set up passwordless certificate. Like in rcp you also can use older method based on .shosts file to allow you to SSH between machines without using a password. There is a wrapper for scp which allows passwords via Expect ( NetSCPExpect - search.cpan.org )

This is a command line utility. GUI SCP clients are rare, as implementing it requires additional functionality (directory listing of the remote host at least). The most popular is WinSCP which actually defaults to the SFTP protocol. Even when operating in SCP mode, clients like...

0 0
8

Not without a lot of messing around.

Of the top of my head you could redirect the output of SCP to a file, then have an AJAX request to a script that parses that file, and when a new line appears (assuming scp increments it's progress bar by seperating lines with \r) the PHP script exits in some way that instructs the browser to increment it's progress bar, then initiate the AJAX process again... and so on until scp terminates.

I have done stuff like this before, and I would say that it's not worth the massive effort for such a small nicety - unless you feel you don't have enough to do already...

It would be much easier to do stuff like this if browsers would let you read ajax.responseText before ajax.readyState == 4, but they don't, so it isn't.

EDIT

Just thought of an alternative approach to this that might be easier in some ways but more difficult in others:

If you put the progress bar in an you wouldn't need to have the huge number of...

0 0
9
...
0 0
10

SCP (Secure Copy) is a command line tool for Linux systems for securely transfer files from local to remote server or vice a versa. SCP uses SSH protocol for transferring files between two systems which is more secure than ftp.

Syntax: (Local to Remote)

Syntax: (Remote to Local)

SCP command required password of remote system. In case you need to configure scp command in script and run with scheduler, you need to configure key based ssh login.

Transfer File Local to Remote Server

Following command will copy myfile.txt from current directory of local system to remote server’s /opt directory using root authentication. We are assuming remote server hostname is example.com.

$ scp myfile.txt [email protected]:/opt/

Transfer File Remote Server to Local

Following command will copy /opt/myfile.txt from remote system to local system’s /opt directory.

$ scp [email protected]ple.com:/opt/myfile.txt /opt/

Define Port with SCP...

0 0
11

I think what you ask is not easily doable, maybe even impossible with basic bash scripting.

Therefore, the following does not really answer your question but provides another approach to your problem.

Instead of using sshpass, you could use the plain scp command with a publickey authentication without password. See [1] if you don't know what it is.

If you intend to use scp in scripts for local use, this is, IMO the way to go:

generate a publickey without password use ssh-copy-id to add your public key to the server

That's already enough to be able to run your command without any prompt:

scp -r me8@host.ca:/cmshome/me/file /home/me/Desktop

For scripts that you want to distribute, sshpass with clear password is certainly not a good idea, you should at least use the sshpass's "-e" flag and let the user provide the password as an environment variable for better security.

In that case, the publickey approach is a little less convenient but it is...

0 0
12

Linux administrator should be familiar with CLI environment. Since GUI mode in Linux servers is not a common to be installed. SSH may the most popular protocol to enable Linux administrator to manage the servers via remote in secure way. Built-in with SSH command there is SCP command. SCP is used to copy file(s) between servers in secure way.

10 Linux SCP Commands

The below command will read as “copy source_file_name” into “destination_folder” at “destination_host” using “username account”.

Basic syntax of SCPscp source_file_name [email protected]_host:destination_folder

There are much parameters in SCP command that you can use. Here are the parameters that may useful on daily basis usage.

Provide the detail information of SCP process using -v parameter

Basic SCP command without parameter will copy the files in background. User will see nothing unless the process is done or some error appears. You can use “-v” parameter to print debug information...

0 0
13

So, if you write a script to automate some copy to your servers... you may use scp. Which is great and printing a nice progress bar if you run it locally. Very clever that if you don't run it from terminal it does not print the progress bar, so it won't pollute your logs... but if you copy tons of gigabytes, you may would be happy to show that progress bar for your user...

Took me a couple of hours to google this :)

So if you run scp via SSH on the remote side:

ssh user@server scp userB@serverB:/dir/mybigfile .

than scp won't print anything, and as I said its cool. But if you really want to get that progress bar :) That's a difficult thing at the first shot.

What I found here:

http://blog.clay.shep.me/2009/06/showing-scp-progress-using-zenity.html

That SCP checks if the terminal is real or not, then decides to print the progress bar or not... luckly ssh can trick the system and allocate a pseudo terminal for us ! And that's the...

0 0