Page not found – ShopingServer Wiki http://wiki.shopingserver.com Tutorials and Articles About Technology and Gadgets Wed, 02 Sep 2020 02:21:07 +0000 en-US hourly 1 https://wordpress.org/?v=5.5.14 http://wiki.shopingserver.com/wp-content/uploads/2018/07/cropped-favicon-150x150.png Page not found – ShopingServer Wiki http://wiki.shopingserver.com 32 32 Mac OS X: Install GCC Compiler with Xcode http://wiki.shopingserver.com/mac-os-x-install-gcc-compiler-xcode/ http://wiki.shopingserver.com/mac-os-x-install-gcc-compiler-xcode/#respond Sat, 06 Jan 2018 10:18:13 +0000 http://wiki.shopingserver.com/?p=18595 I have Mac OS X Mountain Lion. I need to compile a few apps and Perl modules. Then I already installed Xcode from app store but I’m unable to find gcc compiler or make command. How do I install gcc on Mac OS X 10.8.x?

 

Xcode includes command line development tools such as gcc and friends.

Step #1: Install Xcode on a Apple Mac OS X

First, make sure Xcode is installed. If it is not installed on OS X, visit app store and install Xcode.

Fig.01: Make sure Xcode developer tools are install OS X

Step #2: Install gcc/LLVM compiler on OS X

Once installed, open Xcode and visit:

Xcode menu > Preferences > Downloads > choose  Command line tools  > Click  Install  button:

Fig.02: Installing gcc compiler on Mac OS X

 

Xcode will download package and install copies of the core command line tools and system headers into system folders, including the LLVM compiler, linker, and build tools.

Step #3: Verification

Open a terminal app and type the following commands:

$ gcc –version

$ whereis gcc

$ whereis make

 

Sample outputs:

Fig.03: Verify gcc compiler installation on Mountain Lion OS X

Testing sample “Hello world” C program

Create a text file called a.c as follows using a text editor such as vi or cat command:

/* a.c – demo for os x */

#include<stdio.h>

int main(void){

printf( Hello world\n );

return 0;

}

To compile, enter:

$ make a

 

Run it as follows:

$ ./a

 

Sample outputs:

Fig.04: Compiling and running sample “Hello world” C program on Mountain Lion 10.8.4

See also

And, there you have it, the gcc version 4.2.1 installed and working correctly on the latest version of Mac OS X 10.8.4. In Apple’s version of GCC, both cc and gcc are actually symbolic links to the llvm-gcc compiler. Similarly, c++ and g++ are links to llvm-g++. For more information and examples see the following man pages:

$ gcc(1)

$ make(1)

 

This entry is 5 of 13 in the Linux GNU/GCC Compilers Tutorial series. Keep reading the rest of the series:

Ubuntu Linux Install GNU GCC Compiler and Development Environment

Debian Linux Install GNU GCC Compiler and Development Environment

CentOS / RHEL 7: Install GCC (C and C++ Compiler) and Development Tools

Download and Install C, C++ Compiler on Red Hat Enterprise Linux 5 (RHEL)

Mac OS X: Install GCC Compiler with Xcode

Where is My Linux GNU C or GCC Compilers Are Installed?

HowTo: Compile And Run a C/C++ Code In Linux

RHEL / CentOS Linux Install Core Development Tools Automake, Gcc (C/C++), Perl, Python & Debuggers

HowTo Compiling C Program And Creating Executable File Under a Linux / UNIX / *BSD

How To Install ncurses Library on a Linux

Linux Find Out What Compilers Are Installed or Available On The System

Linux Find Out GNU gcc Compiler Version Used To Compile Running Kernel

Howto see output of C program in Linux or UNIX

 

 

]]>
http://wiki.shopingserver.com/mac-os-x-install-gcc-compiler-xcode/feed/ 0
Mac OS X: Wake Up Servers Using Wake-on-LAN ( WOL ) Command Utility http://wiki.shopingserver.com/mac-os-x-wake-servers-using-wake-lan-wol-command-utility/ http://wiki.shopingserver.com/mac-os-x-wake-servers-using-wake-lan-wol-command-utility/#respond Sat, 06 Jan 2018 10:15:08 +0000 http://wiki.shopingserver.com/?p=18591 I know how to send WOL command using Linux or FreeBSD wake command. But, how do I send Wake on LAN (WOL) frames to hosts on a local Ethernet network using Apple OS X Unix operating systems to wake up my servers or nas devices?

 

You need to use the wakeonlan Perl script that generates and transmits a Wake-On-LAN (WOL) “Magic Packet”, used for restarting machines that have been soft powered-down (ACPI D3-warm state).

Method #1: Install wakeonlan using Homebrew

Open the Terminal app and type the following command:

brew install wakeonlan

Sample outputs:

Fig.01: OS X brew install wakeonlan client

Method #2: Download and install wakeonlan Perl script

Open a terminal and type the following curl command:

$ mkdir -p $HOME/bin

$ curl https://raw.githubusercontent.com/jpoliv/wakeonlan/master/wakeonlan -o ~/bin/wakeonlan

$ chmod +x ~/bin/wakeonlan

How do I send WOL on a OS X?

The syntax is:

$ ~/bin/wakeonlan server-mac-address-here

 

For example, if nas01 server has 00:08:9b:c4:30:30 mac address, enter:

$ ~/bin/wakeonlan 00:08:9b:c4:30:30

 

Sample outputs:

Sending magic packet to 255.255.255.255:9 with 00:08:9b:c4:30:30

Other options

-i ip_address

set the destination IP address

default: 255.255.255.255 (the limited broadcast address)

-p port

set the destination port

default: 9 (the discard port)

-f file

uses file as a source of hardware addresses

Apple computer wake for network access (WOL) setting

If you want other users to be able to access your Apple OS X based computer’s shared resources, such as shared printers/files/folders or iTunes playlists, even when your computer is in sleep mode. Open System Preferences > choose “Energy Saver preferences“. This set options that control your computer’s energy use including WOL for all Mac Based server and client systems:

Fig.01: OS X setting WOL

Make sure you select the option “Wake for network access” so that other users can wake up your computer using WOL magic packet.

References

wakeonlan(1) for more information.

Download Wakeonlan: Perl script for waking up computers via Wake-On-LAN magic packets

HowTo: Wake Up Computers Using Linux Command [ Wake-on-LAN ( WOL ) ]

 

 

]]>
http://wiki.shopingserver.com/mac-os-x-wake-servers-using-wake-lan-wol-command-utility/feed/ 0
Mac Os X: Find Out Wireless WI-Fi Connection Speed Rate http://wiki.shopingserver.com/mac-os-x-find-wireless-wi-fi-connection-speed-rate/ http://wiki.shopingserver.com/mac-os-x-find-wireless-wi-fi-connection-speed-rate/#respond Sat, 06 Jan 2018 10:11:09 +0000 http://wiki.shopingserver.com/?p=18585 How do I see my current WI-FI (Wifi) connection speed in Apple Mac OS X?

 

WI-FI allows an electronic device such as Apple laptop, ipad, iPhone and other iDevices to exchange data or connect to the internet wirelessly using radio waves. You can see the current WI-FI speed using any one of the following tools in Mac OS X:

Network Utility.

System Information.

Wireless Network Preferences Menu Bar Icon Shortcut.

airport Command Line Utility.

Method #1: Checking the wireless connection speed using network utility

First, click on Spotlight and type “network utility“. OR press command + space-bar and type “network utility“.

Fig.01: Finding network utility

Make sure you select network utility. Select Info tab and choose Wi-fi (en0 or en1) on the drop-down options. Please note that the Link Speed is your wireless connection speed. In this example, my connection speed is set to 450 Mbit/s (Mega bits per seconds).

Fig.02: Finding the current wireless connection speed using network utility. The WI-FI speed will be displayed as the Link Speed.

Method #2: Checking the wireless connection speed using system information

Click on Spotlight and tye “system information“. OR press cmd+space-bar and then type “system information“. Finally, choose Network and select Wi-Fi. The WI-FI connection information will be displayed on the right.

Fig.03: Finding My Mac Mini’s WI-FI speed using system information. Please note that you may need to scroll down the right side to see all info.

Method #3: Finding wireless status using option key

First, hold down the Option key.

Next, Click on Wireless icon (Airport icon) and you will see information as follows:

Fig.04: Finding extended information about your wi-fi connection

Method #4: Command line utility

Open a terminal. Type the following command:

/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I

Sample outputs:

agrCtlRSSI: -62

agrExtRSSI: 0

agrCtlNoise: -86

agrExtNoise: 0

state: running

op mode: station

lastTxRate: 150

maxRate: 450

lastAssocStatus: 0

802.11 auth: open

link auth: wpa2-psk

BSSID: 50:46:5d:d2:36:8c

SSID: very5_G

MCS: 7

channel: 161,-1

I strongly recommend that you use network utility for ease of use.

 

 

]]>
http://wiki.shopingserver.com/mac-os-x-find-wireless-wi-fi-connection-speed-rate/feed/ 0
HowTo: OS X Take a Screenshot On My Mac Desktop http://wiki.shopingserver.com/howto-os-x-take-screenshot-mac-desktop/ http://wiki.shopingserver.com/howto-os-x-take-screenshot-mac-desktop/#respond Sat, 06 Jan 2018 09:54:52 +0000 http://wiki.shopingserver.com/?p=18563 I can use Shutter app in GNU/Linux to take a screenshot of a specific area, window, whole screen, or even of a website. How do I take a screenshot on my mac book pro/mini desktop using Mac OS X?

 

Shutter application not available on Apple OS X or Apple based systems. However, you can take pictures of the screen (screenshots). They are saved as files on the desktop or put a screenshot in the Clipboard using Mac OS X keyboard shortcuts. No need to download and install paid applications. You can use the following keyboard shortcuts to capture:

The whole screen / desktop.

Part of the screen / desktop.

Part of the menu or toolbar.

Please note that you can also take screenshots using the Grab app.

How do I take a picture of the whole screen?

You need to hold down Command (⌘), and press Shift & 3 keys simultaneously:

Command (⌘)-Shift-3

Pictures of the screenshot is saved as files on the desktop in the following format i.e. file name will be as follows:

Screen Shot 2013-08-09 at 2.57.32 PM

How do I take a picture of part of the screen?

You need to hold down Command (⌘), and press Shift & 4 keys simultaneously:

Command (⌘)-Shift-4

Make sure you drag the cross-hair (X) pointer to select the area. Continue to press the mouse button, release the keys, and then press Shift, Option, or the Space bar while you drag to resize the selection area. When you are ready to take a picture, release the mouse button.

Note: To cancel, press Escape before you release the mouse button.

The default screenshot format is set to .png file.

Say hello to screencapture command

You can use screencapture command from the Terminal to capture images from the screen and save them to a file or the clipboard. The syntax is:

screencapture /path/to/file.jpg

screencapture [option] /path/to/file.jpg

The following command will capture the entire desktop and save it to ~/Desktop/my-shot-1.png file:

screencapture ~/Desktop/my-shot-1.png

 

To view your screenshotp go to desktop or type the following command from the terminal:

open ~/Desktop/my-shot-1.png

 

Pass the -c option to force screen capture to go to the clipboard:

screencapture -c

 

Press command (⌘)-v to paste screenshot in your office or photo editing application.

Pass the -i option to capture screen interactively, by selection or window. The control key will cause the screen shot to go to the clipboard. The space key will toggle between mouse selection and window selection modes. The escape key will cancel the interactive screen shot:

screencapture -i ~/Desktop/my-shot-1.png

 

The following is a list of all supported options:

-c      Force screen capture to go to the clipboard.

 

-C      Capture the cursor as well as the screen.  Only allowed in non-interactive modes.

 

-i      Capture screen interactively, by selection or window.  The control key will cause the screen shot to go to the clipboard.  The space key will

toggle between mouse selection and window selection modes.  The escape key will cancel the interactive screen shot.

 

-m      Only capture the main monitor, undefined if -i is set.

 

-M      Open the taken picture in a new Mail message.

 

-o      In window capture mode, do not capture the shadow of the window.

 

-P      Open the taken picture in a Preview window.

 

-s      Only allow mouse selection mode.

 

-S      In window capture mode, capture the screen instead of the window.

 

-t       Image format to create, default is png (other options include pdf, jpg, tiff and other formats).

 

-T       Take the picture after a delay of , default is 5.

 

-w      Only allow window selection mode.

 

-W      Start interaction in window selection mode.

 

-x      Do not play sounds.

 

-a      Do not capture attached windows.

 

-r      Do not add screen dpi meta data to captured file.

References

KB – PH11229.

screencapture(1) for more information.

 

 

]]>
http://wiki.shopingserver.com/howto-os-x-take-screenshot-mac-desktop/feed/ 0
HowTo: Pronounce Mac OS X http://wiki.shopingserver.com/howto-pronounce-mac-os-x/ http://wiki.shopingserver.com/howto-pronounce-mac-os-x/#respond Sat, 06 Jan 2018 09:50:10 +0000 http://wiki.shopingserver.com/?p=18557 I

am a new Apple Mac book pro user. Is Mac OS X pronounced as “Mac OS E-X” or “Mac OS Ten”? How do you pronounce the Apple Mac os X? How do I find out OS X version using command line tool?

 

Short answer – The Apple Mac OS X is pronounced as “Mac OS Ten”.

How do I find out the current OS X version?

Visit Apple menu > select “About This Mac” to see the current version:

Fig.01 OS X version

From the Fig.01 the current version of Mac OS is “Mac OS Ten” dot eight. Where,

Mac OS name – Mac OS Ten

Major version – 10.8

Update to major version – .4

Pronounced as –  Mac OS Ten dot eight dot four  or  Mac OS Ten point eight point four

Here is output from macOS Sierra:

Fig.02: macOS Sierra

Finding Mac OS X version from command line

To display Mac OS X operating system version information use sw_vars command. Open the Terminal and type the following command:

$ sw_vers

 

Sample outputs:

Fig.03: Finding Mac OS X version using sw_vers command line tool

 

Here is the output from the lastest version of macOS Sierra:

$ sw_vers

ProductName: Mac OS X

ProductVersion: 10.12

BuildVersion: 16A323

Say hello to ‘say’ command line tool

say is command line tool. It uses the Speech Synthesis manager to convert input text to audible speech and either play it through the sound output device chosen in System Preferences or save it to an AIFF file. Open the Terminal and type the following command:

say  Mac OS X

say  Mac OS X .8.4

The following command uses sw_vers as bash command line substitute to find out the current version and pronounce it using the say command:

say $(sw_vers -productName && sw_vers -productVersion | sed  s/10// )

 

 

]]>
http://wiki.shopingserver.com/howto-pronounce-mac-os-x/feed/ 0
Mac OS X: Set / Change $PATH Variable http://wiki.shopingserver.com/mac-os-x-set-change-path-variable/ http://wiki.shopingserver.com/mac-os-x-set-change-path-variable/#respond Sat, 06 Jan 2018 09:45:50 +0000 http://wiki.shopingserver.com/?p=18551 I

need to add dev tools (such as JDK and friends) to my PATH. How do I change $PATH variable in OS X 10.8.x? Where does $PATH get set in OS X 10.8 Mountain Lion?

 

$PATH is nothing but an environment variable on Linux, OS X, Unix-like operating systems, and Microsoft Windows. You can specify a set of directories where executable programs are located using $PATH. The $PATH variable is specified as a list of directory names separated by colon (:) characters. To print the current settings, open the Terminal and then type:

echo  $PATH

OR

printf  %s\n  $PATH

Sample outputs:

Fig.01: Displaying the current $PATH settings using echo / printf on OS X

OS X: Change your PATH environment variable

You can add path to any one of the following method:

$HOME/.bash_profile file using export syntax.

/etc/paths.d directory.

Method #1: $HOME/.bash_profile file

The syntax is as follows:

export PATH=$PATH:/new/dir/location1

export PATH=$PATH:/new/dir1:/dir2:/dir/path/no3

In this example, add /usr/local/sbin/modemZapp/ directory to $PATH variable. Edit the file $HOME/.bash_profile, enter:

vi $HOME/.bash_profile

 

OR

vi ~/.bash_profile

 

Append the following export command:

export PATH=$PATH:/usr/local/sbin/modemZapp

Save and close the file. To apply changes immedialty enter:

source $HOME/.bash_profile

 

OR

. $HOME/.bash_profile

 

Finally, verify your new path settings, enter:

echo $PATH

 

Sample outputs:

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/sbin/modemZapp

Method #2: /etc/paths.d directory

Apple recommends the path_helper tool to generate the PATH variable i.e. helper for constructing PATH environment variable. From the man page:

The path_helper utility reads the contents of the files in the directories /etc/paths.d and /etc/manpaths.d and appends their contents to the PATH and MANPATH environment variables respectively.

(The MANPATH environment variable will not be modified unless it is already set in the environment.)

Files in these directories should contain one path element per line.

Prior to reading these directories, default PATH and MANPATH values are obtained from the files /etc/paths and /etc/manpaths respectively.

To list existing path, enter:

ls -l /etc/paths.d/

 

Sample outputs:

total 16

-rw-r–r–  1 root  wheel  13 Sep 28  2012 40-XQuartz

You can use the cat command to see path settings in 40-XQuartz:

cat /etc/paths.d/40-XQuartz

 

Sample outputs:

/opt/X11/bin

To set /usr/local/sbin/modemZapp to $PATH, enter:

sudo -s  echo  /usr/local/sbin/modemZapp  > /etc/paths.d/zmodemapp

OR use vi text editor as follows to create /etc/paths.d/zmodemapp file:

sudo vi /etc/paths.d/zmodemapp

 

and append the following text:

/usr/local/sbin/modemZapp

Save and close the file. You need to reboot the system. Alternatively, you can close and reopen the Terminal app to see new $PATH changes.

Conclusion

Use $HOME/.bash_profile file when you need to generate the PATH variable for a single user account.

Use /etc/paths.d/ directory via the path_helper tool to generate the PATH variable for all user accounts on the system. This method only works on OS X Leopard and higher.

See also:

Customize the bash shell environments from the Linux shell scripting wiki.

UNIX: Set Environment Variable

Man pages – bash(1), path_helper(8)

 

 

]]>
http://wiki.shopingserver.com/mac-os-x-set-change-path-variable/feed/ 0
SSH Into Google Cloud Compute Engine Instance Using Secure Shell Client http://wiki.shopingserver.com/ssh-google-cloud-compute-engine-instance-using-secure-shell-client/ http://wiki.shopingserver.com/ssh-google-cloud-compute-engine-instance-using-secure-shell-client/#respond Sat, 06 Jan 2018 09:42:41 +0000 http://wiki.shopingserver.com/?p=18547 I

need to set and test my web-app using Google cloud compute engine. How do I connect to an Instance Using ssh on Ubuntu Linux or Apple OS X based system?

 

By default, you can always connect to an instance using ssh. This is useful so you can manage and configure your instances beyond the basic configuration enabled by gcutil or the REST API. The easiest way to ssh into an instance is to use gcutil command from your local Linux / OS X based systems. The following steps are required

Install gcutil/google sdk

Authorize instance

Verify instance status

Create ssh keys

Connect using gcutil or ssh client

Step #1: Install gcutil

gcutil runs on UNIX-based operating systems such as Linux and Mac OS X. To use gcutil, you must have Python 2.6.x or 2.7.x installed on your computer. gcutil does not support Python 3.x. Python is installed by default on most Linux distributions and Mac OS X. Open the Terminal and type the following command or to grab gcutil tool visiting this url.

Debian / Ubuntu / RHEL / CentOS Linux/OS X UNIX user type the following commands:

Open a terminal and type:

Download IT ##

$ wget https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz

$ tar -zxvf google-cloud-sdk.tar.gz

INSTALL IT ##

$ bash google-cloud-sdk/install.sh

 

Sample outputs:

Welcome to the Google Cloud SDK!

 

The Google Cloud SDK is currently in developer preview. To help improve the

quality of this product, we collect anonymized data on how the SDK is used.

You may choose to opt out of this collection now (by choosing  N  at the below

prompt), or at any time in the future by running the following command:

gcloud config set –scope=user disable_usage_reporting true

 

Do you want to help improve the Google Cloud SDK (Y/n)?  n

 

 

This will install all the core command line tools necessary for working with

the Google Cloud Platform.

 

 

The following components will be installed:

——————————————————————————————-

| BigQuery Command Line Tool                                        |     2.0.18 | < 1 MB |

| BigQuery Command Line Tool (Platform Specific)                    |     2.0.18 | < 1 MB |

| Cloud DNS Admin Command Line Interface                            | 2015.04.29 | < 1 MB |

| Cloud SDK Core Command Line Tools                                 |          1 |        |

| Cloud SDK Core Libraries (Platform Specific)                      | 2014.10.20 | < 1 MB |

| Cloud SQL Admin Command Line Interface                            | 2015.04.09 | < 1 MB |

| Cloud Storage Command Line Tool                                   |       4.12 | 2.5 MB |

| Cloud Storage Command Line Tool (Platform Specific)               |        4.6 | < 1 MB |

| Compute Engine Command Line Interface                             | 2015.04.29 | < 1 MB |

| Compute Engine Command Line Tool (deprecated)                     |     1.16.5 | < 1 MB |

| Compute Engine Command Line Tool (deprecated) (Platform Specific) |     1.16.5 | < 1 MB |

| Default set of gcloud commands                                    | 2015.04.29 | < 1 MB |

| Native extensions for gcloud commands (Mac OS X, x86_64)          |     0.15.0 | 4.0 MB |

——————————————————————————————-

 

|- Creating update staging area                             -|

|============================================================|

 

|- Installing: BigQuery Command Line Tool                   -|

|============================================================|

|- Installing: BigQuery Command Line Tool (Platform Spec… -|

|============================================================|

|- Installing: Cloud DNS Admin Command Line Interface       -|

|============================================================|

|- Installing: Cloud SDK Core Command Line Tools            -|

|============================================================|

|- Installing: Cloud SDK Core Libraries (Platform Specific) -|

|============================================================|

|- Installing: Cloud SQL Admin Command Line Interface       -|

|============================================================|

|- Installing: Cloud Storage Command Line Tool              -|

|============================================================|

|- Installing: Cloud Storage Command Line Tool (Platform… -|

|============================================================|

|- Installing: Compute Engine Command Line Interface        -|

|============================================================|

|- Installing: Compute Engine Command Line Tool (depreca… -|

|============================================================|

|- Installing: Compute Engine Command Line Tool (depreca… -|

|============================================================|

|- Installing: Default set of gcloud commands               -|

|============================================================|

|- Installing: Native extensions for gcloud commands (Ma… -|

|============================================================|

 

Creating backup and activating new installation…

 

Update done!

Modify profile to update your $PATH and enable bash completion? (Y/n)?  y

 

The Google Cloud SDK installer will now prompt you to update an rc

file to bring the Google Cloud CLIs into your environment.

 

Enter path to an rc file to update, or leave blank to use

[/Users/veryv/.bash_profile]:

Backing up [/Users/veryv/.bash_profile] to [/Users/veryv/.bash_profile.backup].

[/Users/veryv/.bash_profile] has been updated.

Start a new shell for the changes to take effect.

See how to install gcutil tool to manage Google Compute Engine on Linux / Unix for more information.

Step #2: Authenticating to Google Compute Engine

The syntax is:

gcloud auth login

gcloud auth login –project=YOUR-PROJECT-ID-HERE

If your project id is “apache-cluster”, enter:

gcloud auth –project=apache-cluster

Sample outputs:

Fig.01: Authenticating to Google Compute Engine using gcutil command

 

Open a web browser, and go to the specified URL. Click the Grant Access link. The page will display an authorization code. Copy this code. Paste the authorization code into the waiting gcutil auth terminal and press enter. Type the following command to cache project-id:

gcloud config set project YOUR-PROJECT-ID-HERE

Step #3: Verify instance status

Type the following command:

$ gcloud compute instances list

 

Sample outputs:

NAME       ZONE         MACHINE_TYPE INTERNAL_IP   EXTERNAL_IP     STATUS

instance-1 asia-east1-c f1-micro     10.240.xx.yyy 104.155.xxx.zzz RUNNING

Note: instance-1 instance running in asia-east1-c zone.

Step #4: Create ssh keys

The syntax is:

gcloud compute ssh instance_name_here

gcloud compute ssh USER@instance_name_here

gcloud compute ssh USER@instance_name_here — arg1 arg2

gcloud compute –project PROJECT_ID_HERE ssh instance_name_here

In this example, connect to db1 instance using ssh:

$ gcloud compute ssh db1

WARNING: Consider passing  –zone=us-central1-a  to avoid the unnecessary zone lookup which requires extra API calls.

INFO: Zone for db1 detected as us-central1-a.

WARNING: You don t have an ssh key for Google Compute Engine. Creating one now…

Enter passphrase (empty for no passphrase): TYPE-YOUR-PASSPHRASE-HERE

Enter same passphrase again: TYPE-YOUR-PASSPHRASE-HERE

INFO: Updated project with new ssh key. It can take several minutes for the instance to pick up the key.

INFO: Waiting 300 seconds before attempting to connect.

gcutil creates local files to store your public and private key, and copies your public key to the project. By default, gcutil stores ssh keys in the following files on your local system:

$HOME/.ssh/google_compute_engine – Your private key

$HOME/.ssh/google_compute_engine.pub – Your public key

Step #5: Connect using gcutil or ssh client

The syntax is:

gcloud compute ssh instance_name_here

gcloud compute ssh USER@instance_name_here –zone NOZE_NAME_HERE

OR

ssh -o UserKnownHostsFile=/dev/null -o CheckHostIP=no -o StrictHostKeyChecking=no -i $HOME/.ssh/google_compute_engine -A -p 22 $USER@TYPE-GOOGLE-COMPUTE-ENGINE-PUBLIC-IP-HERE

In this example, connect to the ‘instance-1’ instance using gcloud tool:

gcloud compute ssh instance-1

Sample outputs:

For the following instances:

– [instance-1]

choose a zone:

[1] asia-east1-c

[2] asia-east1-a

[3] asia-east1-b

[4] europe-west1-d

[5] europe-west1-c

[6] europe-west1-b

[7] us-central1-c

[8] us-central1-b

[9] us-central1-a

[10] us-central1-f

Please enter your numeric choice:  1

 

Warning: Permanently added  104.155.xxx.zzz  (RSA) to the list of known hosts.

[vivek@instance-1 ~]$

In this example, connect to the db1 (public ip 1.2.3.4) instance using ssh command:

ssh -o UserKnownHostsFile=/dev/null -o CheckHostIP=no -o StrictHostKeyChecking=no -i $HOME/.ssh/google_compute_engine -A -p 22 vivek@1.2.3.4

Sample sessions:

Fig.02: Connecting to an Instance Using ssh

To SSH into ‘db3’ in zone asia-east1-c, run:

gcloud compute ssh db3 –zone asia-east1-c

You can also run a command on the virtual machine. For example, to get a snapshot of the guest’s process tree, run:

gcloud compute ssh db3 –zone asia-east1-c –command  ps -ejH

If you are using the Google container virtual machine image, you can SSH into one of your containers with:

gcloud compute ssh db3 –zone asia-east1-c –container CONTAINER

How do I login as root user?

For security reasons, the standard Google do not provide the ability to ssh in directly as root. The instance creator and any users that were added using the –authorized_ssh_keys flag or the metadata sshKeys value are automatically administrators to the account, with the ability to run sudo without requiring a password. Type the following command to switch to root user:

sudo -s

Sample session:

Fig.03: Root Access and Instance Administrators using the ‘sudo -s’ command on Google compute instance

Optional: Update your gcloud tools

Type the following command:

gcloud components update

Sample outputs:

The following components will be updated:

———————————————————————–

| BigQuery Command Line Tool                    |     2.0.18 | < 1 MB |

| Cloud DNS Admin Command Line Interface        | 2015.04.29 | < 1 MB |

| Cloud SDK Core Libraries                      | 2015.04.29 | 1.8 MB |

| Cloud SDK Core Libraries (Platform Specific)  | 2014.10.20 | < 1 MB |

| Cloud SQL Admin Command Line Interface        | 2015.04.09 | < 1 MB |

| Cloud Storage Command Line Tool               |       4.12 | 2.5 MB |

| Compute Engine Command Line Interface         | 2015.04.29 | < 1 MB |

| Compute Engine Command Line Tool (deprecated) |     1.16.5 | < 1 MB |

———————————————————————–

The following components will be installed:

———————————————————————————-

| Default set of gcloud commands                           | 2015.04.29 | < 1 MB |

| Native extensions for gcloud commands (Mac OS X, x86_64) |     0.15.0 | 4.0 MB |

———————————————————————————-

 

Do you want to continue (Y/n)?  y

 

Creating update staging area…

 

Uninstalling: BigQuery Command Line Tool … Done

Uninstalling: Cloud DNS Admin Command Line Interface … Done

Uninstalling: Cloud SDK Core Libraries … Done

Uninstalling: Cloud SDK Core Libraries (Platform Specific) … Done

Uninstalling: Cloud SQL Admin Command Line Interface … Done

Uninstalling: Cloud Storage Command Line Tool … Done

Uninstalling: Compute Engine Command Line Interface … Done

Uninstalling: Compute Engine Command Line Tool (deprecated) … Done

 

Installing: BigQuery Command Line Tool … Done

Installing: Cloud DNS Admin Command Line Interface … Done

Installing: Cloud SDK Core Libraries … Done

Installing: Cloud SDK Core Libraries (Platform Specific) … Done

Installing: Cloud SQL Admin Command Line Interface … Done

Installing: Cloud Storage Command Line Tool … Done

Installing: Compute Engine Command Line Interface … Done

Installing: Compute Engine Command Line Tool (deprecated) … Done

Installing: Default set of gcloud commands … Done

Installing: Native extensions for gcloud commands (Mac OS X, x86_64) … Done

 

Creating backup and activating new installation…

 

Done!

References:

$HOME/.bash_profile file example.

Google Compute Engine documentation.

Man pages: ssh(1),bash(1)

 

 

]]>
http://wiki.shopingserver.com/ssh-google-cloud-compute-engine-instance-using-secure-shell-client/feed/ 0
Mac OS X: Terminal Download File Command http://wiki.shopingserver.com/mac-os-x-terminal-download-file-command/ http://wiki.shopingserver.com/mac-os-x-terminal-download-file-command/#respond Sat, 06 Jan 2018 09:26:32 +0000 http://wiki.shopingserver.com/?p=18531 I

often need to download files using the Terminal. However, I am unable to find the wget command on OS X. How do download files from the web via the Mac OS X bash command line option?

 

You need to use a tool (command) called curl. It is a tool to transfer data from or to a server, using one of the following supported protocols

FTP

HTTP

HTTPS

FTPS

POP3

SFTP

SMTPS

SMTP and more.

This command is designed to work without user interaction.

curl command syntax

The syntax is:

curl  url

curl [option]  url

curl -O  url

curl -L -O  url

curl -o output.file.name.here  url-here

curl -o foo.pdf  http://server1.cyberciti.biz/foo.pdf

Examples

Open the Terminal and then type the following command to grab “Mastering vim” in pdf format from www.cyberciti.biz server:

curl -o mastering-vim.pdf  http://www.cyberciti.biz/files/mastering-vi-vim.pdf

Sample outputs:

Fig.01: curl command in action

 

The -o option write output to a file called mastering-vim.pdf instead of screen. You can skip the -o option and use the -O (capital letter O) to write (save) output to a local file named like the remote file we get. Only the file part of the remote file is used, the path is cut off:

curl -O http://www.cyberciti.biz/files/mastering-vi-vim.pdf

ls -l *.pdf

How do I specify multiple URLs or parts of URLs?

The syntax is:

# grab files from server1.cyberciti.biz, server2.cyberciti.biz, server3.cyberciti.biz

curl -O http://server{1,2,3}.cyberciti.biz/

curl -O http://server{1,2,3}.cyberciti.biz/foo.pdf

grab latest reports from US, UK, India FTP servers ##

curl -O ftp://intranet.site.{us,uk,in}.lic.net.in/reports/latest[a-z].tar.gz

You can get sequences of alphanumeric series by using []. In this example, grab invoices-1.pdf, invoices-2.pdf, …, invoices-1000.pdf using curl command:

curl -O ftp://ftp.cyberciti.biz/invoices-[1-1000].pdf

You can grab urls with leading zeros as follows:

curl -O ftp://ftp.cyberciti.biz/images-[001-300].png

You can combine various techniques to build complex download url structure as follows:

curl -O ftp://ftp.cyberciti.biz/backups-us-[a-z].tar.gz

curl -O http://server1.cyberciti.biz/music[1997-2000]/series[1-20]/dump{a,b,c,d,e,f}.tar.gz

You can set a step counter for the ranges to get every Nth number or letter:

grab http://server1.cyberciti.biz/files/foo1.txt, http://www.cyberciti.biz/files/foo3.txt, http://www.cyberciti.biz/files/foo5.txt ##

curl -O http://server1.cyberciti.biz/files/foo[1-10:2].txt

 

grab bar-a.pdf, bar-c.pdf, bar-e.pdf, and so on ##

curl -O http://server1.cyberciti.biz/files/bar-[a-z:2].pdf

DISPLAYING A PROGRESS BAR

You can force curl to show progress as a simple progress bar instead of the standard, more informational, meter:

curl -# -O http://www.cyberciti.biz/files/mastering-vi-vim.pdf

Sample outputs:

################################################################## 100.0%

DEALING WITH URL REDIRECTION

The following is recommended syntax for servers that may do http redirect before downloading files. Other servers may hide actual download file names.

curl -L -o  file.name.here   http://example.com/download.php?fileID=foo

Consider the following filezilla download url from sourceforge foss hosting platform:

Problems ##

# 1. Long ulr name with special characters in it

# 2. Url hides actual download file name

# 3. Url does http 301 redirect to pick nearest mirror

# —————————————————–

http://downloads.sourceforge.net/project/filezilla/FileZilla_Client/3.7.3/FileZilla_3.7.3_i686-apple-darwin9.app.tar.bz2?r=http%3A%2F%2Fsourceforge.net%2F&ts=1381651492&use_mirror=ncu

To avoid problems, use the following syntax:

****************** TIP *************************************** ##

a) Put all urls in single-quotes to avoid nasty shell surprises

b) The -L option follows url redirection

c) The -o  file  write file to given name

****************** TIP *************************************** ##

curl -L -o  filezilla.tar.bz2   http://downloads.sourceforge.net/project/filezilla/FileZilla_Client/3.7.3/FileZilla_3.7.3_i686-apple-darwin9.app.tar.bz2?r=http%3A%2F%2Fsourceforge.net%2F&ts=1381651492&use_mirror=ncu

Sample outputs:

Fig.02: Put the URL in single-quotes and accept url redirection with the -L option

SAVE BANDWIDTH

You can pass the –compressed option to http based urls to request a compressed response using one of the algorithms curl supports, and save the uncompressed document. If this option is used and the server sends an unsupported encoding, curl will report an error:

curl -L -O –compressed  http://server1.cyberciti.biz/large.report-tab.html

DOWNLOAD A FILE USING USERNAME AND PASSWORD

The syntax is:

Security alert: Anything (username/password) done over HTTP/FTP is completely open to interception. Do not pass username/passwords using ftp/http protocols.

## Insecure examples ##

curl ftp://username:passwd@ftp1.cyberciti.biz:21/path/to/backup.tar.gz

curl http://username:passwd@server1.cyberciti.biz/file/path/data.tar.gz

 

Secure examples SSL/HTTPS/SFTP etc ##

curl –ftp-ssl -u UserName:PassWord ftp://ftp1.cyberciti.biz:21/backups/07/07/2012/mysql.blog.sql.tar.gz

 

SFTP example ##

curl -u userNameHere sftp://home1.cyberciti.biz/~/docs/resume.pdf

Check out our previous video tutorial on curl command for more information:

 

(Video 01: curl Command Line Download Examples For FTP / HTTP Protocols)

Recommended readings

More – Linux / Unix: curl Command Download File Examples

Linux / Unix: curl Command Pass Host Headers

See curl(1) for more information.

 

 

]]>
http://wiki.shopingserver.com/mac-os-x-terminal-download-file-command/feed/ 0
Mac OS X: Install Go Programming Language http://wiki.shopingserver.com/mac-os-x-install-go-programming-language/ http://wiki.shopingserver.com/mac-os-x-install-go-programming-language/#respond Sat, 06 Jan 2018 09:03:50 +0000 http://wiki.shopingserver.com/?p=18503 H

ow do I install Go language on Apple Mac OS X? How to setup GO lanuage on Mac OS X? How do I install Go language version 1.2+ on OS X?

 

Go or golang, is a programming language initially developed at Google by Robert Griesemer, Rob Pike, and Ken Thompson. Just like Linux kernel it has many contributors from the open source community. From the official project site:

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. Go is distributed under a BSD-style license. It is expressive, concise, clean, and efficient. Its concurrency mechanisms make it easy to write programs that get the most out of multicore and networked machines, while its novel type system enables flexible and modular program construction. Go compiles quickly to machine code yet has the convenience of garbage collection and the power of run-time reflection. It’s a fast, statically typed, compiled language that feels like a dynamically typed, interpreted language.

Install Xcode and gcc

Fig.01: Installing Xcode on OS X

 

First, you need to use the gcc that comes with Xcode. See how to install and use Xcode on Apple Mac OS X for more information.

Installing Golang on Mac OS X

Google provides the package file for OS X. All you have to do is visit this page and grab the latest version. Once downloaded, open it, and follow the prompts to install the Go tools. The package installs the Go distribution to /usr/local/go directory:

Golang installing on OS X using wizard

Golang install # 2

Golang install # 3

Golang – enter admin password

Golang install # 5

Golang install Completed

Verify your installation

Open the Terminal and type the following commands:

$ ls -l /usr/local/go

 

Sample outputs:

total 120

-rw-r–r–   1 root  wheel  13577 Nov 29 03:13 AUTHORS

-rw-r–r–   1 root  wheel  19578 Nov 29 03:13 CONTRIBUTORS

-rw-r–r–   1 root  wheel   1479 Nov 29 03:13 LICENSE

-rw-r–r–   1 root  wheel   1303 Nov 29 03:13 PATENTS

-rw-r–r–   1 root  wheel   1112 Nov 29 03:13 README

-rw-r–r–   1 root  wheel      5 Nov 29 03:16 VERSION

drwxr-xr-x   2 root  wheel    272 Nov 29 03:13 api

drwxr-xr-x   2 root  wheel    170 Nov 29 03:15 bin

drwxr-xr-x   4 root  wheel    136 Nov 29 03:15 blog

drwxr-xr-x   8 root  wheel   1292 Nov 29 03:13 doc

-rw-r–r–   1 root  wheel   1150 Nov 29 03:13 favicon.ico

drwxr-xr-x   3 root  wheel    510 Nov 29 03:13 include

drwxr-xr-x   3 root  wheel    102 Nov 29 03:13 lib

drwxr-xr-x  22 root  wheel    816 Nov 29 03:16 misc

drwxr-xr-x   6 root  wheel    204 Nov 29 03:14 pkg

-rw-r–r–   1 root  wheel     26 Nov 29 03:13 robots.txt

drwxr-xr-x   7 root  wheel    782 Nov 29 03:13 src

drwxr-xr-x  16 root  wheel   6800 Nov 29 03:13 test

Type the following command to display Go environment information:

$ go env

 

Sample outputs:

GOARCH= amd64

GOBIN=

GOCHAR= 6

GOEXE=

GOHOSTARCH= amd64

GOHOSTOS= darwin

GOOS= darwin

GOPATH=

GORACE=

GOROOT= /usr/local/go

GOTOOLDIR= /usr/local/go/pkg/tool/darwin_amd64

TERM= dumb

CC= gcc

GOGCCFLAGS= -g -O2 -fPIC -m64 -pthread -fno-common

CXX= g++

CGO_ENABLED= 1

Writing your first Go program

Create a text file called hello.go using a text editor such as vi/vim:

$ vi hello.go

 

Append the following code:

/* hello.go – My first Golang program */

package main

import  fmt

func main() {

fmt.Printf( Hello, world\n )

}

Test and run hello.go, enter:

$ go run hello.go

 

Sample outputs:

Hello, world

To build an executable i.e. compile packages and dependencies into an executable file, enter:

$ go build hello.go

 

You will get an executable file called hello in the current directory:

$ ls -l hello

-rwxr-xr-x  1 vivek  wheel  2188368 Dec  2 16:07 hello

$ file hello

hello: Mach-O 64-bit executable x86_64

You can run hello program as follows:

$ ./hello

Getting help

The go command is a tool for managing Go source code. To see basic help, type:

$ go help

 

Sample outputs:

Go is a tool for managing Go source code.

 

Usage:

 

go command [arguments]

 

The commands are:

 

build       compile packages and dependencies

clean       remove object files

env         print Go environment information

fix         run go tool fix on packages

fmt         run gofmt on package sources

get         download and install packages and dependencies

install     compile and install packages and dependencies

list        list packages

run         compile and run Go program

test        test packages

tool        run specified go tool

version     print Go version

vet         run go tool vet on packages

 

Use  go help [command]  for more information about a command.

 

Additional help topics:

 

c           calling between Go and C

gopath      GOPATH environment variable

importpath  import path syntax

packages    description of package lists

testflag    description of testing flags

testfunc    description of testing functions

 

Use  go help [topic]  for more information about that topic.

To get more information on specific topic, type:

go help topicHere

go help build

go help build | less

References:

See the Golang home page and documenation for more information.

 

 

]]>
http://wiki.shopingserver.com/mac-os-x-install-go-programming-language/feed/ 0
Mac OS X Sierra Install wget Network Downloader Utility http://wiki.shopingserver.com/mac-os-x-sierra-install-wget-network-downloader-utility/ http://wiki.shopingserver.com/mac-os-x-sierra-install-wget-network-downloader-utility/#respond Sat, 06 Jan 2018 08:56:47 +0000 http://wiki.shopingserver.com/?p=18495 I

recently learned that “wget” can continue getting a partially-downloaded (resume download) file. I am unable to find wget command on Mac OS X. How do I install install wget on Mac OS X (Mountain Lion/ Mavericks / Snow Leopard)? How can I install wget in Mac OS X without 3rd-party repo such as Homebrew or MacPorts?

 

You can install the latest version of GNU/wget and many other open source software without using Homebrew or MacPorts. The steps are as follows to install wget on macOS Sierra using either Homebrew or source code:

Easy method #1: Install Homebrew and type command ‘brew install wget‘ on macOS Sierra.

Source code method #2:

Download, compile and install OpenSSL

Download, compile and install wget on macOS Sierra

Let use see both methods in detailed.

Method #1: Install wget using brew (recommended method)

Trust me this is the best and easy method to install wget using Homebrew:

Install Homebrew

$ /usr/bin/ruby -e  $(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)

Install wget

$ brew install wget

 

Sample outputs:

Updating Homebrew…

==> Downloading https://homebrew.bintray.com/bottles/wget-1.19.1.sierra.bottle.tar.gz

################################################################## 100.0%

==> Pouring wget-1.19.1.sierra.bottle.tar.gz

?  /usr/local/Cellar/wget/1.19.1: 10 files, 1.6MB

Use wget

$ /usr/local/bin/wget url

$ /usr/local/bin/wget url/file.tar.gz

$ /usr/local/bin/wget https://www.cyberciti.biz/

 

That is all, and you need to stop reading the rest. Please note that the rest of the following tutorial covers wget command installation using the source code method.

Method #2: Install wget using source code (recommended for advanced users only)

You need to install a free app called Xcode. It includes command line development tools such as gnu/gcc and friends. See how to install GCC Compiler with Xcode for more information.

Fig.01: Install gcc compiler on Mac OS X

 

I installed command line tools using the following command:

$ xcode-select –install

Step #1: Download gnu/wget source code

Use curl command as follows to download the latest gnu/wget from the official project site. Open the Terminal and than type the following commands:

$ cd /tmp

$ curl -O http://ftp.gnu.org/gnu/wget/wget-1.15.tar.gz

$ ls -l

 

Sample outputs:

Fig.02: Downloading wget source code with the curl utility

Step #2: Extract files

Use the tar command to extract files on OS X as follows:

$ tar xvf wget-1.15.tar.gz

 

Sample outputs:

x wget-1.15/

x wget-1.15/doc/

x wget-1.15/doc/stamp-vti

x wget-1.15/doc/texi2pod.pl

x wget-1.15/doc/Makefile.in

….

..

x wget-1.15/NEWS

x wget-1.15/configure

x wget-1.15/ChangeLog

x wget-1.15/MAILING-LIST

Step #3: Configure, Compile and Install GNU/wget on OS X

First, cd to the wget-1.15 directory using cd command:

$ cd wget-1.15

 

To configure wget, enter:

$ ./configure –with-ssl=openssl

 

Sample outputs:

Configure: configuring for GNU Wget 1.15

checking for a BSD-compatible install… /usr/bin/install -c

checking whether build environment is sane… yes

checking for a thread-safe mkdir -p… build-aux/install-sh -c -d

checking for gawk… no

checking for mawk… no

checking for nawk… no

checking for awk… awk

….

..

configure: creating ./config.status

config.status: creating Makefile

config.status: creating src/Makefile

config.status: creating doc/Makefile

config.status: creating util/Makefile

config.status: creating po/Makefile.in

config.status: creating tests/Makefile

config.status: creating tests/WgetTest.pm

config.status: creating lib/Makefile

config.status: creating src/config.h

config.status: executing depfiles commands

config.status: executing po-directories commands

config.status: creating po/POTFILES

config.status: creating po/Makefile

To compile wget on OS X, enter:

$ make

 

Sample outputs:

/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-recursive

Making all in lib

rm -f alloca.h-t alloca.h && \

{ echo  /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ ; \

cat ./alloca.in.h; \

} > alloca.h-t && \

mv -f alloca.h-t alloca.h

….

..

gcc  -O2 -Wall   -o wget cmpt.o connect.o convert.o cookies.o ftp.o css_.o css-url.o ftp-basic.o ftp-ls.o hash.o host.o html-parse.o html-url.o http.o init.o log.o main.o netrc.o progress.o ptimer.o recur.o res.o retr.o spider.o url.o warc.o utils.o exits.o build_info.o  version.o ftp-opie.o openssl.o http-ntlm.o ../lib/libgnu.a -liconv  -lssl -lcrypto -lz -ldl -lz -lz

Making all in doc

./texi2pod.pl -D VERSION= 1.15  ./wget.texi wget.pod

/usr/bin/pod2man –center= GNU Wget  –release= GNU Wget 1.14  wget.pod > wget.1

Making all in po

Making all in tests

make[2]: Nothing to be done for `all .

Making all in util

make[2]: Nothing to be done for `all .

make[2]: Nothing to be done for `all-am .

To install wget, enter:

$ sudo make install

Find out wget location on OS X

By default wget will be installed at the /usr/local/bin/wget. You can use the whereis utility (or type -a) to check the wget location, enter:

$ whereis wget

 

OR

$ type -a wget

 

If you do not see output, edit $HOME/.bash_profile or $HOME/.bashrc and add/edit/append PATH as follows:

export PATH=${PATH}:/usr/local/bin

 

Save and close the file.

How do I use wget command?

The basic syntax is:

wget url

wget http://www.cyberciti.biz/

wget ftp://url/

 

To see wget version, type:

$ wget –version

 

Sample outputs:

Installed wget on macOS Sierra

How do I update installed gnu/wget on OS X?

Warning: The following method only works if you installed gnu/wget earlier using source code based method as described above. Do not use the following method if you installed wget using Homebrew or MacPorts.

A note about installing wget on macOS Sierra using source code

You need to first install the latest version of openssl:

Step #1: Grab and install latest openssl version 1.19.1 using source code ###

$ cd /tmp/

$ curl -O https://www.openssl.org/source/openssl-1.1.0e.tar.gz

$ tar -zxvf openssl-1.1.0e.tar.gz

$ cd openssl-1.1.0e

$ ./config

$ make

$ sudo make install

 

Finally install wget using the following method:

Step #2: Grab and install wget version 1.19.1 using source code ###

$ cd /tmp

$ curl -O http://ftp.gnu.org/gnu/wget/wget-1.19.1.tar.gz

$ tar -zxvf wget-1.19.1.tar.gz

$ cd wget-1.19.1

$ export OPENSSL_CFLAGS= -I/usr/local/include

$ export OPENSSL_LIBS= -L/usr/local/lib -lssl -lcrypto -lz

$ ./configure –with-ssl=openssl

$ make

$ sudo make install

$ /usr/local/bin/wget url

See also

I recommend the following resources for usage and examples on both wget and curl commands:

wget: An intro to your ultimate command line downloader

See how to use wget alternative curl on OS X to download files.

See wget(1).

GNU/wget home page.

And there you have it, gnu/wget installed from directly source code without using 3rd party repos.

 

 

]]>
http://wiki.shopingserver.com/mac-os-x-sierra-install-wget-network-downloader-utility/feed/ 0