LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-15-2020, 02:42 AM   #1
Janus84
Member
 
Registered: Sep 2019
Location: New Zealand
Distribution: Debian, Mint
Posts: 61

Rep: Reputation: Disabled
custom terminal command


There's so much on this topic out there but I'm still confused.
I had the objective to run an .exe file without typing
Code:
$ cd (when somewhere else in file system)
$ wine winbox64.exe
I only want to type
Code:
$ winbox
regardless of where I am.


I have created a bash script winbox.sh
Code:
#! /bin/bash

#launch MikroTik Winbox using Wine
wine winbox64.exe
which allows me to use
Code:
winbox.sh
But I still need to be in ./ directory which is fine for now

So I tried to create an alias in my bashrc file:
Code:
# User specific aliases and functions
alias winbox='bash ./winbox.sh'
but this still happens
Code:
$ winbox
bash: winbox: command not found
If someone can please correct me, I'd like to also create another command that would launch a .jar file that I use all the time.
 
Old 06-15-2020, 03:25 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
use full path to winbox.sh
 
2 members found this post helpful.
Old 06-15-2020, 03:31 AM   #3
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by Janus84 View Post
So I tried to create an alias in my bashrc file:
That's not sufficient. You have to execute your bashrc file, either by logging on or this way:
Code:
source $HOME/.bashrc
However, the winbox alias will try to run ./winbox.sh. This only works if the current directory contains winbox.sh.

Rather than juggling with aliases, copy winbox.sh into a directory that is in your path. For example, in .bashrc or .bash_profile, ensure that PATH contains $HOME/bin. For example:
Code:
PATH=$PATH:$HOME/bin
Then make winbox.sh executable and move it to $HOME/bin:
Code:
chmod +x winbox.sh
mv winbox.sh $HOME/bin/winbox
Once you have activated your PATH by logging on again, you should be able to run winbox no matter what is your current directory.

EDIT: pan64's suggestion works as well.

Last edited by berndbausch; 06-15-2020 at 03:32 AM.
 
1 members found this post helpful.
Old 06-15-2020, 05:36 AM   #4
Janus84
Member
 
Registered: Sep 2019
Location: New Zealand
Distribution: Debian, Mint
Posts: 61

Original Poster
Rep: Reputation: Disabled
Wink

Quote:
Originally Posted by pan64 View Post
use full path to winbox.sh
That fixed it, thanks
 
Old 06-15-2020, 05:47 AM   #5
Janus84
Member
 
Registered: Sep 2019
Location: New Zealand
Distribution: Debian, Mint
Posts: 61

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by berndbausch View Post
Rather than juggling with aliases, copy winbox.sh into a directory that is in your path.
I have added PATH into bashrc but
Code:
PATH=$PATH:$HOME/bin
was showing in red.
I have changed to
Code:
PATH="$HOME/bin:$PATH"
would that be ok?

Now I have
Code:
~/bin$ ls -l
total 8
-rwxr-xr-x 1 root root 73 Jun 15 22:15 ubnt.sh
-rwxr-xr-x 1 root root 67 Jun 15 22:14 winbox.sh
but
Code:
~/bin$ winbox
bash: winbox: command not found
I did log out and then back in.
 
Old 06-15-2020, 06:46 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
in windows you can omit the extension, because the OS will try different extensions to find the real executable or script. But in linux you need to specify exactly the same name. So if it was named winbox.sh you need to type winbox.sh. Obviously you can create an alias which will replace the alias winbox to something usable (like: alias winbox=winbox.sh).
 
1 members found this post helpful.
Old 06-15-2020, 07:19 AM   #7
Roken
Member
 
Registered: Oct 2011
Location: Warrington, UK
Distribution: Arch local, Debian on VPS, several RPIs.
Posts: 300
Blog Entries: 1

Rep: Reputation: 55
or just rename winbox.sh to winbox
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: 179 Color Schemes For Your Gtk-Based Linux Terminal (Gnome Terminal, Tilix, Xfce Terminal, More) LXer Syndicated Linux News 0 07-28-2019 04:50 AM
[SOLVED] Change terminal for Thunar: 'Open Terminal Here' custom action.... andrew.46 Slackware 2 01-17-2012 05:46 AM
terminal not opening up : accidentally modified its custom command vanna Linux - Newbie 4 03-13-2009 05:07 PM
custom install cd base-config custom mithereal Debian 6 09-11-2005 03:48 PM
custom geforce video card--custom module? bandofmercy Linux - Hardware 3 10-14-2004 06:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration