Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8056577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:44:59+00:00 2026-06-05T08:44:59+00:00

Can anyone tell me what is wrong with this code? It is supposed to

  • 0

Can anyone tell me what is wrong with this code? It is supposed to be a help me do a speed test on a remote server. I get the following error when trying to execute it via SSH using PUTTY:
syntax error: unexpected end of file

    ssh_server=$1
    test_file=".scp-test-file"
    # Optional: user specified test file size in kBs
    if test -z "$2"
    then
        # default size is 10kB ~ 10mB
        test_size="10000"
    else
        test_size=$2
    fi
    # generate a 10000kB file of all zeros
    echo "Generating $test_size kB test file..."
    `dd if=/dev/zero of=$test_file bs=$(echo "$test_size*1024" | bc) \
        count=1 &> /dev/null`
    # upload test
    echo "Testing upload to $ssh_server..."
    up_speed=`scp -v $test_file $ssh_server:$test_file 2>&1 | \
        grep "Bytes per second" | \
        sed "s/^[^0-9]*\([0-9.]*\)[^0-9]*\([0-9.]*\).*$/\1/g"`
    up_speed=`echo "($up_speed*0.0009765625*100.0+0.5)/1*0.01" | bc`
    # download test
    echo "Testing download to $ssh_server..."
    down_speed=`scp -v $ssh_server:$test_file $test_file 2>&1 | \
        grep "Bytes per second" | \
        sed "s/^[^0-9]*\([0-9.]*\)[^0-9]*\([0-9.]*\).*$/\2/g"`
    down_speed=`echo "($down_speed*0.0009765625*100.0+0.5)/1*0.01" | bc`
    # clean up
    echo "Removing test file on $ssh_server..."
    `ssh $ssh_server "rm $test_file"`
    echo "Removing test file locally..."
    `rm $test_file`
    # print result
    echo ""
    echo "Upload speed:   $up_speed kB/s"
    echo "Download speed: $down_speed kB/s"

Any Ideas? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T08:45:00+00:00Added an answer on June 5, 2026 at 8:45 am

    Remove the backticks from around those commands that are not part of an assignment to a variable.

    Also, make sure there are no tabs, spaces or carriage returns after the line-continuation backslashes (and no carriage returns at all in the file).

    Instead of multiplying by the ugly “0.0009765625”, divide by 2^17 or 131072.

    Why are you dividing by 1? Just omit that. Divide by 100 instead of multiplying by 0.01.

    Even though it’s unlikely that the variables’ contents contain whitespace, you should make it a habit to always quote variables when they are expanded.

    #!/bin/bash
    ssh_server=$1
    test_file=".scp-test-file"
    # Optional: user specified test file size in kBs
    if test -z "$2"
    then
        # default size is 10mB
        test_size="10000"
    else
        test_size=$2
    fi
    # generate a file of all zeros
    echo "Generating $test_size kB test file..."
    dd if=/dev/zero of="$test_file" bs=$(echo "$test_size*1024" | bc) \
        count=1 &> /dev/null
    # upload test
    echo "Testing upload to $ssh_server..."
    up_speed=$(scp -v "$test_file" "$ssh_server:$test_file" 2>&1 | \
        sed -n '/Bytes per second/s/^[^0-9]*\([0-9.]*\)[^0-9]*\([0-9.]*\).*$/\1/p')
    up_speed=$(echo "scale = 2; $up_speed / 131072 * 100.0" | bc -l)
    # download test
    echo "Testing download to $ssh_server..."
    down_speed=$(scp -v "$ssh_server:$test_file" "$test_file" 2>&1 | \
        sed -n '/Bytes per second/s/^[^0-9]*\([0-9.]*\)[^0-9]*\([0-9.]*\).*$/\2/p')
    down_speed=$(echo "scale = 2; $down_speed / 131072 * 100.0" | bc -l)
    # clean up
    echo "Removing test file on $ssh_server..."
    ssh $ssh_server "rm '$test_file'"
    echo "Removing test file locally..."
    rm "$test_file"
    # print result
    echo
    echo "Upload speed:   $up_speed kB/s"
    echo "Download speed: $down_speed kB/s"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone tell me what's wrong with this code? It's giving me an error
Can anyone help me debug this program? The following is server code : package
Can anyone tell me what could be wrong with the following code! Im this
Can anyone tell me whats wrong with this code. It's supposed to list the
Can anyone tell me what's wrong with this code? class Dataset < ActiveRecord::Base has_many
Can anyone tell me what is wrong with this code? public abstract class BoardTestBean{
Can anyone tell me what's wrong in this code: #!/usr/local/bin/python import os import string,
Can anyone tell me whats wrong with this code? <?php $feedID = '28241415'; $oddsArray
Can anyone tell me what is going wrong with this code? I tried to
can anyone tell me what is wrong with this code: CC = C:\Program Files\Microsoft

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.