Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Run .sh file in one line command


  • Please log in to reply
6 replies to this topic

#1 wseng92

wseng92

  • Members
  • 33 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Malaysia
  • Local time:02:57 AM

Posted 19 July 2018 - 09:40 PM

How to start sh file in one line command ? This is how I normally start sh file in the specific path

user@user:~$ cd idea-IC-171.4424.56/bin
user@user:~/idea-IC-171.4424.56/bin$ ./idea.sh 

If I would like to start the command in one line like below, I will get error

user@user:~/idea-IC-171.4424.56/bin$ cd idea-IC-171.4424.56/bin/idea.sh
bash: cd: idea-IC-171.4424.56/bin/idea.sh: No such file or directory


BC AdBot (Login to Remove)

 


#2 wseng92

wseng92
  • Topic Starter

  • Members
  • 33 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Malaysia
  • Local time:02:57 AM

Posted 19 July 2018 - 10:56 PM

Solution: Add a ; to separate commands

cd idea-IC-171.4424.56/bin ; ./idea.sh



#3 rp88

rp88

  • Members
  • 3,082 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Local time:06:57 PM

Posted 21 July 2018 - 02:52 PM

Remember that sometimes you might need to run chmod on the .sh file first, to give it execute permissions if they are not already present. Only do this for files you trust the source of.
Back on this site, for a while anyway, been so busy the last year.

My systems:2 laptops, intel i3 processors, windows 8.1 installed on the hard-drive and linux mint 17.3 MATE installed to USB

#4 sflatechguy

sflatechguy

  • BC Advisor
  • 2,266 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:01:57 PM

Posted 21 July 2018 - 04:12 PM

I think you guessed your problem -- you can't cd into idea.sh because it's not a directory.

 

You could also cd idea-IC-171.4424.56/bin && ./idea.sh . This will only run the .sh script if you can successfully cd into the /bin directory.

 

More possible chaining operators:  https://www.tecmint.com/chaining-operators-in-linux-with-practical-examples/



#5 Mike_Walsh

Mike_Walsh

    Bleepin' 'Puppy' nut..!!


  • Members
  • 1,462 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:King's Lynn, UK
  • Local time:06:57 PM

Posted 21 July 2018 - 07:26 PM

@ wseng92:-

 

The other way you could do it would be to save the original command as a separate shell script, with an easily identifiable name.

 

Save it to /usr/local/bin (this is the correct location for locally produced scripts). Then, you could send it to the desktop, and start it from there. If you want to, give it an icon, and rename it. Google/DuckDuckGo are both good sources of icons. Just search for 'PNG icons for (whatever)'. PNG icons work best, due to their transparent 'backdrop'.

 

If you know how to, you could also add it to your Menu, with a .desktop file in /usr/share/applications. Both of these methods will give you a single-click way to start your script.

 

 

Mike.  :wink:


Distros:- Multiple 'Puppies'..... and Anti-X 16.1

My Puppy BLOG ~~~  My Puppy PACKAGES

Compaq Presario SR1916UK; Athlon64 X2 3800+, 3 GB RAM, WD 500GB Caviar 'Blue', 32GB Kingspec PATA SSD, 3 TB Seagate 'Expansion' external HDD, ATI Radeon Xpress 200 graphics, Dell 15.1" pNp monitor (1024 x 768), TP-Link PCI-e USB 3.0 card, Logitech c920 HD Pro webcam, self-powered 7-port USB 2.0 hub

Dell Inspiron 1100; 2.6 GHz 400FSB P4, 1.5 GB RAM, 64GB KingSpec IDE SSD, Intel 'Extreme' graphics, 500GB Seagate 'Expansion' external HDD, M$ HD-3000 'Lifecam'.

 

KXhaWqy.gifFQ8nrJ3.gif

 

 


#6 rufwoof

rufwoof

  • Members
  • 151 posts
  • OFFLINE
  •  
  • Local time:06:57 PM

Posted 22 July 2018 - 03:05 PM

Save it to /usr/local/bin (this is the correct location for locally produced scripts). 

 

/usr/local/bin is for binaries of programs local to the site. If a single user/personal specific script it should be in ~/bin. If correct file/folder permissions are applied /usr/local/bin write access is restricted (requires root) and requests by users to add a script there should be scrutinised first, keeping in mind that a buggy script could introduce system wide security risks.

 

Basically /bin is for pre /usr being mounted binaries. /sbin is the same, but where superuser (root) privileges are required. Same for /usr/bin and /usr/sbin, but where /usr will have already been mounted. They are typically supplied scripts. /usr/local/bin and /usr/local/sbin are for additional admin managed scripts specifically for the local system. ~/bin is for scripts individual users write for themselves.


Edited by rufwoof, 22 July 2018 - 03:07 PM.

OpenBSD (-current)


#7 wseng92

wseng92
  • Topic Starter

  • Members
  • 33 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Malaysia
  • Local time:02:57 AM

Posted 29 July 2018 - 09:51 PM

thanks guys  :love4u:​ 






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users