DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 9th June 2020
jonsec jonsec is offline
Fdisk Soldier
 
Join Date: Jul 2019
Posts: 71
Default [OpenBSD] bash script in bin folder like CentOS

how i can run script by typing name of file in console like CentOS?

CentOS example :
Code:
root# mkdir 600 ~/bin
root# vi bin/mycmd
echo "$@"

root# mycmd arg1 arg2 arg3 argN
Reply With Quote
  #2   (View Single Post)  
Old 9th June 2020
Head_on_a_Stick's Avatar
Head_on_a_Stick Head_on_a_Stick is offline
Real Name: Matthew
Bitchy Nerd Elitist
 
Join Date: Dec 2015
Location: London
Posts: 461
Default

Add ~/bin to the user's PATH by placing this stanza in ~/.profile:
Code:
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi
If you're using xenodm then either place the stanza in ~/.xsession instead or source ~/.profile in that file.
__________________
Are you infected with Wetiko?
Reply With Quote
  #3   (View Single Post)  
Old 9th June 2020
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,977
Default

In the BSD/Unix world, executable text files -- scripts -- must be headed by a "hashbang" indicating the program that interprets and runs the script, such as:
Code:
#!/bin/sh
or for bash on OpenBSD, which is a third party program stored in /usr/local/bin:
Code:
#!/usr/local/bin/bash
Also, the file mode must allow execution -- see chmod(1).

Last edited by jggimi; 9th June 2020 at 07:03 PM. Reason: Added file mode, and comments about path to the executable
Reply With Quote
  #4   (View Single Post)  
Old 10th June 2020
jonsec jonsec is offline
Fdisk Soldier
 
Join Date: Jul 2019
Posts: 71
Thumbs up

thanks to Head_on_a_Stick and jggimi.

worked.
Reply With Quote
Reply

Tags
bash, bin, script, shell

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script to resize and optimize images using ImageMagick and jpegoptim demifiend Programming 17 1st November 2017 07:41 PM
Bash script cannot execute - Is a directory guitarscn Programming 8 6th November 2010 10:25 PM
[Solved] How to make 2 separate arguments in 1 bash script? guitarscn Programming 1 31st August 2010 09:12 PM
Mounting six CentOS iso images on OpenBSD J65nko Guides 6 25th November 2009 10:58 PM
Is bash included in OpenBSD? bsdnewbie999 OpenBSD General 21 2nd August 2008 02:57 AM


All times are GMT. The time now is 10:44 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick