Sponsored Content
Top Forums Shell Programming and Scripting Files test How to recover a specific variable Post 302981918 by rovf on Wednesday 21st of September 2016 08:27:17 AM
Old 09-21-2016
Quote:
Originally Posted by Arnaudh78
Thank for your reply, I use #!/bin/bash, So I work in Bash ? I'm beginner, I'm open at all.what do you recommend?
This depends on how you invoke your script.

If the script as executable rights, and you invoke it by typing the script name, the #! line defines, which language processor will be used to run your script. In your case, it is the bash executable stored in the /bin directory.

Alternatively, you can invoke the language processor to be used explicitly from the command line. For instance, if I write bash myfile, the file myfile should better be a bash script (and not zsh or ksh or awk....), as it will be executed under bash. The same applies to other languages - zsh, perl, ruby, ....

Now as for the recommendation. It is difficult to give a recommendation without starting a language war, because most programmers seem to be very picky when it comes to choosing one language over another, and everyone has his favorite pet, so note that I give here only my personal opinion, and others might advice you differently.

As for shell programming, after having had long experience with bash and a little bit experience with ksh, csh and tcsh, I turned to zsh, because I found that quite a few things are simpler to do in zsh than in the other languages. I yet have to see something which is easier to do in bash than in zsh (there must be something). The main drawback of zsh is that fewer people use it, so if you get stuck, you might have to search longer for someone to help. However, I got every zsh question answered by someone so far.

As second language, I tend to use Ruby (after having collected experience with awk, Perl, Python and Tcl), because I found it more expressive than the others and much easier to learn.

Of course one thing to consider it, where your script will run, and how much control you have on the software at the target machine. If I know that there is no zsh installed on the target machine, and I don't even have an account there, it would not be wise to deliver a zsh script. Having said this, even when using bash, you should make sure that you either develop your scripts with the same bash version than the one available on the target host, or write your scripts in a way that they will likely run under each version. This might turn out to be difficult, in particular for someone who doesn't have much experience yet.

If you run your programs only on your own machine, it is up to you what tools you choose.
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Recover deleted files

Is there a Unix tool, like in Novell, to recover accidentally deleted files? (2 Replies)
Discussion started by: kuultak
2 Replies

2. AIX

recover deleted files

How to recover deleted files in AIX ? (1 Reply)
Discussion started by: vjm
1 Replies

3. UNIX for Dummies Questions & Answers

How to test for a specific file size

Hello, In my shell program, I need to test for a specific size of a text file before it can be imported into an oracle table. If the size is less than that number, my program should stop processing. What is the correct command to do this test? Thanks! (1 Reply)
Discussion started by: GEBRAUN
1 Replies

4. Shell Programming and Scripting

Is there a way to recover files deleted using rm command???

Hi All, I just mistakingly deleted some files using rm command.Is there a way to get it back?i work on Solaris 10 Thanks, Kumar (1 Reply)
Discussion started by: kumarsaravana_s
1 Replies

5. UNIX for Dummies Questions & Answers

Recover data from 2 files then combine

Using dd or similar tools to recover data from 2 damaged cdroms, I need a way to then combine the 2 files, 1 from each cd, and make a good file: this all result from finding that certain cd's tops scratch easily even when using the "proper" cd markers, hence making the file useless, however the... (1 Reply)
Discussion started by: saint65
1 Replies

6. UNIX for Dummies Questions & Answers

how to recover deleted files in unix

Hi Experts, by mistake i deleted some files that are very important to the project. is there any way that i can recover those files,there is no backup for that but the details of the file we know. This will be a great help. Thanks (5 Replies)
Discussion started by: namishtiwari
5 Replies

7. UNIX for Dummies Questions & Answers

Recover directory/files in unix

Hi Guys I accidently deleted a directory( and the files in it) in unix using 'rm -rf' :) Is there any procedure/script/command to recover the same? Your help is highly apperciated -thanks Subramanya (1 Reply)
Discussion started by: sgbhat
1 Replies

8. Shell Programming and Scripting

Need to Recover Deleted Files

Hi, By mistake, executed the following command : rm -rf * and ALL files got deleted. But I need to get back these files as they are very very important. Please help me how to recover this file. Its Urgent for me please. Thanks in advance. (6 Replies)
Discussion started by: unx100
6 Replies
getusershell(3C)					   Standard C Library Functions 					  getusershell(3C)

NAME
getusershell, setusershell, endusershell - get legal user shells SYNOPSIS
#include <unistd.h> char *getusershell(void); void setusershell(void); void endusershell(void); DESCRIPTION
The getusershell() function returns a pointer to a legal user shell as defined by the system manager in the file /etc/shells. If /etc/shells does not exist, the following locations of the standard system shells are used in its place: /bin/bash /bin/csh /bin/jsh /bin/ksh /bin/pfcsh /bin/pfksh /bin/pfsh /bin/sh /bin/tcsh /bin/zsh /sbin/jsh /sbin/pfsh /sbin/sh /usr/bin/bash /usr/bin/csh /usr/bin/jsh /usr/bin/ksh /usr/bin/pfcsh /usr/bin/pfksh /usr/bin/pfsh /usr/bin/sh /usr/bin/tcsh /usr/bin/zsh /usr/xpg4/bin/sh The getusershell() function opens the file /etc/shells, if it exists, and returns the next entry in the list of shells. The setusershell() function rewinds the file or the list. The endusershell() function closes the file, frees any memory used by getusershell() and setusershell(), and rewinds the file /etc/shells. RETURN VALUES
The getusershell() function returns a null pointer on EOF. BUGS
All information is contained in memory that may be freed with a call to endusershell(), so it must be copied if it is to be saved. SunOS 5.10 30 Aug 2004 getusershell(3C)
All times are GMT -4. The time now is 05:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy