how to run .sh file on windows using cygwin? - linux

I am beginner of cygwin terminal. I am trying to run *.sh file on windows 8 using command ./file_name.sh, but it gives error given below....
Using prebuilt externals
ERROR: Cannot find 'make' program. Please install Cygwin make package
or define the GNUMAKE variable to point to it.
I have installed cygwin in F drive, I google this error and set the variable path in computer properties > advance system properties > variable environment > path >edit and variable path is ;F:\cygwin\bin
But does not work. How can i solve this problem??
Here is my script
`# set params`
NDK_ROOT=/cygdrive/f/Android/android-ndk-r9b
COCOS2DX_ROOT=/cygdrive/f/Android/cocos2d-2.0-rc2-x-2.0.1
GAME_ROOT=$COCOS2DX_ROOT/molatx
GAME_ANDROID_ROOT=$GAME_ROOT/proj.android
RESOURCE_ROOT=$GAME_ROOT/Resources
buildexternalsfromsource=
usage(){
cat << EOF
usage: $0 [options]
Build C/C++ native code using Android NDK
OPTIONS:
-s Build externals from source
-h this help
EOF
}
while getopts "s" OPTION; do
case "$OPTION" in
s)
buildexternalsfromsource=1
;;
h)
usage
exit 0
;;
esac
done
`# make sure assets is exist`
if [ -d $GAME_ANDROID_ROOT/assets ]; then
rm -rf $GAME_ANDROID_ROOT/assets
fi
mkdir $GAME_ANDROID_ROOT/assets
`# copy resources`
for file in $RESOURCE_ROOT/*
do
if [ -d "$file" ]; then
cp -rf "$file" $GAME_ANDROID_ROOT/assets
fi
if [ -f "$file" ]; then
cp "$file" $GAME_ANDROID_ROOT/assets
fi
done
`# copy icons (if they exist)`
file=$GAME_ANDROID_ROOT/assets/Icon-72.png
if [ -f "$file" ]; then
cp $file $GAME_ANDROID_ROOT/res/drawable-hdpi/icon.png
fi
file=$GAME_ANDROID_ROOT/assets/Icon-48.png
if [ -f "$file" ]; then
cp $file $GAME_ANDROID_ROOT/res/drawable-mdpi/icon.png
fi
file=$GAME_ANDROID_ROOT/assets/Icon-32.png
if [ -f "$file" ]; then
cp $file $GAME_ANDROID_ROOT/res/drawable-ldpi/icon.png
fi
if [[ $buildexternalsfromsource ]]; then
echo "Building external dependencies from source"
$NDK_ROOT/ndk-build -C $GAME_ANDROID_ROOT \
NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/source
else
echo "Using prebuilt externals"
$NDK_ROOT/ndk-build -C $GAME_ANDROID_ROOT \
NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt
fi

You have to install make package using cygwin "setup.exe" wizard.
Check what programming language is your script compiling because the compiler of that language will be also dependencies of your script.
Probably you will need to install some libraries too.

Your Windows system path is different to your Cygwin path. If you install the required packages using cygwin setup they will already be available in your $PATH.
Run cygwin setup an install: make , automake , gcc , gcc-c++

Related

JAVA_HOME is not set, cannot proceed. (Installing Apache Spark on Linux)

How I am here.
Running Command:
opt/develop/spark-3.3.1$ sudo ./dev/make-distribution.sh -pHADOOP-3 Dhadoop.version=3.2.4 -Pyarn --name custom-spark --pip --r --tgz -Psparkr -Phive -Phive-thriftserver -Pmesos -Pyarn -Pkubernetes
The script (make-distribution.sh), apparently, is not reading the value of the variable i.e., $JAVA_HOME.
Running Command:
/opt/develop/spark-3.3.1$ echo $JAVA_HOME
Shows expected result: /usr/lib/jvm/jdk-19.0.1
Attempted:
Well, added to the file /opt/develop/spark-3.3.1/sbin/spark-config.sh
export JAVA_HOME="/usr/lib/jvm/jdk-19.0.1" export PATH=$PATH:$JAVA_HOME/bin
did not seem to change the result of Running command.
Logging-out and logging back in is also of no avail.
Note-1:
My JAVA_HOME is also set in /etc/profile.d/my-envvars file as:
export JAVA_HOME="/usr/lib/jvm/jdk-19.0.1" export PATH=$PATH:$JAVA_HOME/bin
Note-2: commands java --version and javac --version appears to be working okay.
The file: /opt/develop/dev/make-distribution.sh
Reads:
`
set -o pipefail
set -e
set -x
# Figure out where the Spark framework is installed
SPARK_HOME="$(cd "`dirname "$0"`/.."; pwd)"
DISTDIR="$SPARK_HOME/dist"
MAKE_TGZ=false
MAKE_PIP=false
MAKE_R=false
NAME=none
MVN="$SPARK_HOME/build/mvn"
function exit_with_usage {
set +x
echo "make-distribution.sh - tool for making binary distributions of Spark"
echo ""
echo "usage:"
cl_options="[--name] [--tgz] [--pip] [--r] [--mvn <mvn-command>]"
echo "make-distribution.sh $cl_options <maven build options>"
echo "See Spark's \"Building Spark\" doc for correct Maven options."
echo ""
exit 1
}
# Parse arguments
while (( "$#" )); do
case $1 in
--tgz)
MAKE_TGZ=true
;;
--pip)
MAKE_PIP=true
;;
--r)
MAKE_R=true
;;
--mvn)
MVN="$2"
shift
;;
--name)
NAME="$2"
shift
;;
--help)
exit_with_usage
;;
--*)
echo "Error: $1 is not supported"
exit_with_usage
;;
-*)
break
;;
*)
echo "Error: $1 is not supported"
exit_with_usage
;;
esac
shift
done
if [ -z "$JAVA_HOME" ]; then # THIS SHOULD EVALUATE FALSE.
# Fall back on JAVA_HOME from rpm, if found
if [ $(command -v rpm) ]; then
RPM_JAVA_HOME="$(rpm -E %java_home 2>/dev/null)"
if [ "$RPM_JAVA_HOME" != "%java_home" ]; then
JAVA_HOME="$RPM_JAVA_HOME"
echo "No JAVA_HOME set, proceeding with '$JAVA_HOME' learned from rpm"
fi
fi
if [ -z "$JAVA_HOME" ]; then
if [ `command -v java` ]; then
# If java is in /usr/bin/java, we want /usr
JAVA_HOME="$(dirname $(dirname $(which java)))"
fi
fi
fi
if [ -z "$JAVA_HOME" ]; then # This SHOULD EVALUATE FALSE. APPARENTLY, IT DOES NOT
echo "Error: JAVA_HOME is not set, cannot proceed."
# I Should not be here, but I am!
exit -1
fi
`
Your problem lies within the fact that you're executing your script with sudo, which does not preserve environment variables by default.
As a small demonstration, consider the following:
someone#somewhere:~/my-path$ export SOMEVAR="testmyvar"
someone#somewhere:~/my-path$ echo $SOMEVAR
testmyvar
someone#somewhere:~/my-path$ sudo bash -c 'echo $SOMEVAR'
As you can see, when executing a command with sudo, you don't preserve all of your environment variables.
There is luckily quite an easy fix for that: use sudo -E (that does preserve environment variables, you can find that option in the man page of sudo)
So in our little example a bit higher:
someone#somewhere:~/my-path$ sudo -E bash -c 'echo $SOMEVAR'
testmyvar
You see that the -E option does what you want it to do!
Hope this fixes your problem :)

can't translate my program via debian package but with autotools can

i use autotools as build system also i use gettext in my code for Translations.
I have few .po files (de.po, es.po and th.po ) and with autotools no problem to get them working. After:
./configure,
make
sudo make install
the program and the Translations .mo files get installed.
To testing that i open a terminal and change the locale e.g :
$ export LANG=de_DE.UTF-8
$ ./myprogram
and the translations works!.
I do with the same source code a debian deb package.
During the deb installation in a .posinst script i deploy the translations mo files to the locale destination (docklight is the program name):
#!/bin/bash
set -e
# check for locale dir (LIVE SYSTEMS don't have it)
if [ -d "/usr/local/share/locale" ]; then
podir="/usr/lib/docklight/docklight.data/po"
if [ -d ${podir} ]; then
cd ${podir}
PO_LINGUAS=$( if test -r LINGUAS; then grep -v "^\#" LINGUAS; fi)
linguas=$PO_LINGUAS
for lang in $linguas; do
dir=/usr/local/share/locale/$lang/LC_MESSAGES;
# check for locale dir (LIVE SYSTEMS don't have it)
if [ ! -d $dir ]; then
continue;
fi
# check for po file
if [ ! -f "$lang.po" ]; then
continue;
fi
file=`echo $lang | sed 's,.*/,,'`.gmo \
&& rm -f $file && /usr/local/bin/msgfmt -o $file "$lang.po"
/bin/bash install-sh -d $dir; \
if test -r $lang.gmo; then \
/usr/bin/install -c -m 644 $lang.gmo $dir/docklight.mo; \
echo "installing $lang.gmo as $dir/docklight.mo"; \
else \
/usr/bin/install -c -m 644 ./$lang.gmo $dir/docklight.mo; \
echo "installing ./$lang.gmo as" \
"$dir/docklight.mo"; \
fi
done
fi
fi
the generated Translations .mo files are correct and get installed on the locale folder for the language:
dir=/usr/local/share/locale/$lang/LC_MESSAGES;
exact the same like the build process with autotools.
After testing the languages:
$ export LANG=de_DE.UTF-8
$ ./myprogram
my program does not have any translation.
I don't know where the problem is. The deb installation works correct!
is something more that i need to care for the creation of a debian deb package?
As far as I understood, when you get myprogramm.mo files in place you should get the program translated.
Any ideas about that?
Thanks in advance for any help.
if find the solution:
I just need to set the PROGRAMNAME_LOCALEDIR path where the mo file are.
The gettext initialization can find the mo files and then everything gets translate. Works!
bindtextdomain(GETTEXT_PACKAGE, PROGRAMNAME_LOCALEDIR);
%s\n",domain,GETTEXT_PACKAGE,PROGRAMNAME_LOCALEDIR);
bind_textdomain_codeset - set encoding of message transā€lations
btdcodeset = bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
Thank you all.

How to get Linux command line functions for Windows?

I am following Caffe on this tutorial. I am using Windows so I don't have the Linux functions. Is there an easy way I can get Linux functions ? When I run the shell script it launches Bash which immediately closes. It doesn't seem to download anything.
#!/usr/bin/env sh
# This scripts downloads the mnist data and unzips it.
DIR="$( cd "$(dirname "$0")" ; pwd -P )"
cd "$DIR"
echo "Downloading..."
for fname in train-images-idx3-ubyte train-labels-idx1-ubyte t10k-images-idx3-ubyte t10k-labels-idx1-ubyte
do
if [ ! -e $fname ]; then
echo "done"
wget --no-check-certificate http://yann.lecun.com/exdb/mnist/${fname}.gz
gunzip ${fname}.gz
echo "done"
fi
done
You can consider installing such an environment, e.g. start with CYGWIN:
https://www.cygwin.com/

Shell Script for local file

I am trying to install freeSwitch in my CentOS 6.5 machine. I have followed the instructions given at https://confluence.freeswitch.org/display/FREESWITCH/CentOS+6.
While executing make command I am facing problem of time out while downloading a library from files.freeswitch.org at terminal.
While if I paste the url in browser I am able to download the file. The instruction for downloading is written at a script file.
Now I want to change the script so that instead of doing a wget from url it should read it from the local disk. As I am very new to shell scripting. How I should change the script to get the desired result. the file name of script is getlib.sh and the script is
Please help
#!/bin/sh
##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*-
TAR=/bin/gtar
ZCAT=/bin/gunzip
BZIP=/usr/bin/bzip2
XZ=/usr/bin/xz
WGET=/usr/bin/wget
CURL=/usr/bin/curl
if [ -f "$WGET" ]; then
DOWNLOAD_CMD=$WGET
elif [ -f "$CURL" ]; then
DOWNLOAD_CMD="$CURL -O"
fi
if [ -n "`echo $1 | grep '://'`" ]; then
base=$1/
tarfile=$2
else
base=http://files.freeswitch.org/downloads/libs/
tarfile=$1
fi
uncompressed=`echo $tarfile | sed 's/\(\(\.tar\.gz\|\.tar\.bz2\|\.tar\.xz\)\|\(\.tgz\|\.tbz2\)\)$//'`
case `echo $tarfile | sed 's/^.*\.//'` in
bz2|tbz2) UNZIPPER=$BZIP ;;
xz) UNZIPPER=$XZ ;;
gz|tgz|*) UNZIPPER=$ZCAT ;;
esac
if [ ! -d $tarfile ]; then
if [ ! -f $tarfile ]; then
rm -fr $uncompressed
$DOWNLOAD_CMD $base$tarfile
if [ ! -f $tarfile ]; then
echo cannot find $tarfile
exit 1
fi
fi
if [ ! -d $uncompressed ]; then
$UNZIPPER -c -d $tarfile | $TAR -xf -
fi
fi
exit 0
if [ -n "`echo $1 | grep '://'`" ]; then
base=$1/
tarfile=$2
Your script is already setup to use your downloaded file. Just run your script giving it the PATH as $1 and the downloaded filename as $2. For example if the script name is freeSwitch and the PATH where you downloaded the tarball is /home/user1/files/ and the tarball name is freeswitch.tar.bz2, then simply run:
./freeSwitch /home/user1/files/ freeswitch.tar.bz2
That should start the script using the tarball from your local disk instead of trying to download it from http://files.freeswitch.org/downloads/libs/. NOTE you need the trailing / at the end of PATH. Good luck!

identify and delete all x64 architecture files

I have a folder with many .a and .o libraries for i386 and x64
I want to find and remove all the x64 libraries?
I know objdump can help but I don't know how to use it (maybe using a bash script with 'find' or 'sed') to make a list of the files and remove them.
You can try the following script (it runs from the same folder with the libraries). I suggest you replace the "rm -f" with an echo first, to check the list of files to be deleted.
#!/bin/bash
for f in *; do
fileInfo=$(file $f)
echo $fileInfo | grep -q "ELF 64-bit"
exitCode=$?
if [ $exitCode -eq 0 ]; then
rm -f "$f"
fi
done

Resources