Re: [OpenIndiana-discuss] timeout display for input prompt

2021-03-08 Thread Thebest videos
excellent!. it works. thanks a lot

On Mon, Mar 8, 2021 at 4:56 PM Richard L. Hamilton 
wrote:

>
>
> > On Mar 8, 2021, at 06:11, Thebest videos 
> wrote:
> >
> > great! that works. but i have another problem. i'm using prompt in
> secured
> > way as "read -s -t 10" but I need to store the output in one variable. as
> > below. but nothing is storing in $req variable
> >
> > #!/bin/csh
> >
> > set pass=`cat file | grep rootpw | grep -o '".*"' | sed 's/"//g'`
>
> Useless cat award. Instead of
> cat file | grep rootpw
> use
> grep rootpw file
>
>
> > if ( "$pass" == "edjos" ) then
> >
> >   echo  "You are at default password. kindly change the password in
> > 10secs……."
> >
> > set req=`bash -c 'read -s -t 10'`
>
> No, my previous example was precise. The bash needs to echo the variable
> read (or ${REPLY} if no variable was given on the read command), because
> the output of the bash command is what takes the place of the command
> substitution in the csh. The quoting needs care to get right, too.
>
> set req=`bash -c 'read -s -t 10 ;echo "${REPLY}"'`
>
>
> > echo $req
> >
> > if ( "$req" == "" ) then
> >
> >   echo "No password entered. So continuing with default password"
> >
> >else
> >
> >  sed -i.bak "/rootpw/s/edjos/$req/"  file
> >
> >   endif
> >
> > endif
> >
> >
> > On Mon, Mar 8, 2021 at 4:02 PM Richard L. Hamilton 
> > wrote:
> >
> >> If it has to be pure csh (without any helpers), you're probably out of
> >> luck, because csh is crippled when it comes to scripting.
> >>
> >> You could probably use a command substitution on a one-liner of your
> bash
> >> from the csh script:
> >>
> >> #! /bin/csh
> >> set myvar=`bash -c 'read -t 10 ;echo "${REPLY}"'`
> >> echo "$myvar"
> >>
> >> For anything much trickier, getting the quoting right will be a killer,
> so
> >> the helper should probably be a separate bash script.
> >>
> >> Picking csh to script it is just wrong, because it has too many missing
> >> capabilities, isn't predictable enough in how it behaves, doesn't
> >> necessarily behave as portably as other shells, etc.
> >> http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/ <
> >> http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/>
> >>
> >>
> >>> On Mar 8, 2021, at 04:38, Thebest videos 
> >> wrote:
> >>>
> >>>
> >>> hi Team,
> >>>
> >>> Im trying create a csh script.
> >>> requirement:
> >>> when i script runs it asks for user input. prompt should wait for
> 10secs.
> >>> if not then exit the script.
> >>> i have solution for bash script where i can use read -t 10 username.
> but
> >> i
> >>> want same in csh
> >>> ```
> >>> #!/bin/csh
> >>> echo -n "username:"
> >>> set req = $<
> >>> echo "username is $req"
> >>> sed -i.bak "/rootpw/s/edjos/$req/" /boot/loader.conf
> >>> ```
> >>> and for advance level, the message should look like "prompts end in
> >> 10(this
> >>> number should decrease and lively should visible the timeout secs)"
> >>> ___
> >>> openindiana-discuss mailing list
> >>> openindiana-discuss@openindiana.org
> >>> https://openindiana.org/mailman/listinfo/openindiana-discuss
> >>>
> >>
> >> ___
> >> openindiana-discuss mailing list
> >> openindiana-discuss@openindiana.org
> >> https://openindiana.org/mailman/listinfo/openindiana-discuss
> >>
> > ___
> > openindiana-discuss mailing list
> > openindiana-discuss@openindiana.org
> > https://openindiana.org/mailman/listinfo/openindiana-discuss
> >
>
>
> ___
> openindiana-discuss mailing list
> openindiana-discuss@openindiana.org
> https://openindiana.org/mailman/listinfo/openindiana-discuss
>
___
openindiana-discuss mailing list
openindiana-discuss@openindiana.org
https://openindiana.org/mailman/listinfo/openindiana-discuss


Re: [OpenIndiana-discuss] timeout display for input prompt

2021-03-08 Thread Richard L. Hamilton


> On Mar 8, 2021, at 06:11, Thebest videos  wrote:
> 
> great! that works. but i have another problem. i'm using prompt in secured
> way as "read -s -t 10" but I need to store the output in one variable. as
> below. but nothing is storing in $req variable
> 
> #!/bin/csh
> 
> set pass=`cat file | grep rootpw | grep -o '".*"' | sed 's/"//g'`

Useless cat award. Instead of
cat file | grep rootpw
use
grep rootpw file


> if ( "$pass" == "edjos" ) then
> 
>   echo  "You are at default password. kindly change the password in
> 10secs……."
> 
> set req=`bash -c 'read -s -t 10'`

No, my previous example was precise. The bash needs to echo the variable read 
(or ${REPLY} if no variable was given on the read command), because the output 
of the bash command is what takes the place of the command substitution in the 
csh. The quoting needs care to get right, too.

set req=`bash -c 'read -s -t 10 ;echo "${REPLY}"'`


> echo $req
> 
> if ( "$req" == "" ) then
> 
>   echo "No password entered. So continuing with default password"
> 
>else
> 
>  sed -i.bak "/rootpw/s/edjos/$req/"  file
> 
>   endif
> 
> endif
> 
> 
> On Mon, Mar 8, 2021 at 4:02 PM Richard L. Hamilton 
> wrote:
> 
>> If it has to be pure csh (without any helpers), you're probably out of
>> luck, because csh is crippled when it comes to scripting.
>> 
>> You could probably use a command substitution on a one-liner of your bash
>> from the csh script:
>> 
>> #! /bin/csh
>> set myvar=`bash -c 'read -t 10 ;echo "${REPLY}"'`
>> echo "$myvar"
>> 
>> For anything much trickier, getting the quoting right will be a killer, so
>> the helper should probably be a separate bash script.
>> 
>> Picking csh to script it is just wrong, because it has too many missing
>> capabilities, isn't predictable enough in how it behaves, doesn't
>> necessarily behave as portably as other shells, etc.
>> http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/ <
>> http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/>
>> 
>> 
>>> On Mar 8, 2021, at 04:38, Thebest videos 
>> wrote:
>>> 
>>> 
>>> hi Team,
>>> 
>>> Im trying create a csh script.
>>> requirement:
>>> when i script runs it asks for user input. prompt should wait for 10secs.
>>> if not then exit the script.
>>> i have solution for bash script where i can use read -t 10 username. but
>> i
>>> want same in csh
>>> ```
>>> #!/bin/csh
>>> echo -n "username:"
>>> set req = $<
>>> echo "username is $req"
>>> sed -i.bak "/rootpw/s/edjos/$req/" /boot/loader.conf
>>> ```
>>> and for advance level, the message should look like "prompts end in
>> 10(this
>>> number should decrease and lively should visible the timeout secs)"
>>> ___
>>> openindiana-discuss mailing list
>>> openindiana-discuss@openindiana.org
>>> https://openindiana.org/mailman/listinfo/openindiana-discuss
>>> 
>> 
>> ___
>> openindiana-discuss mailing list
>> openindiana-discuss@openindiana.org
>> https://openindiana.org/mailman/listinfo/openindiana-discuss
>> 
> ___
> openindiana-discuss mailing list
> openindiana-discuss@openindiana.org
> https://openindiana.org/mailman/listinfo/openindiana-discuss
> 


___
openindiana-discuss mailing list
openindiana-discuss@openindiana.org
https://openindiana.org/mailman/listinfo/openindiana-discuss


Re: [OpenIndiana-discuss] timeout display for input prompt

2021-03-08 Thread Thebest videos
great! that works. but i have another problem. i'm using prompt in secured
way as "read -s -t 10" but I need to store the output in one variable. as
below. but nothing is storing in $req variable

#!/bin/csh

set pass=`cat file | grep rootpw | grep -o '".*"' | sed 's/"//g'`

if ( "$pass" == "edjos" ) then

   echo  "You are at default password. kindly change the password in
10secs……."

set req=`bash -c 'read -s -t 10'`

echo $req

 if ( "$req" == "" ) then

   echo "No password entered. So continuing with default password"

else

  sed -i.bak "/rootpw/s/edjos/$req/"  file

   endif

endif


On Mon, Mar 8, 2021 at 4:02 PM Richard L. Hamilton 
wrote:

> If it has to be pure csh (without any helpers), you're probably out of
> luck, because csh is crippled when it comes to scripting.
>
> You could probably use a command substitution on a one-liner of your bash
> from the csh script:
>
> #! /bin/csh
> set myvar=`bash -c 'read -t 10 ;echo "${REPLY}"'`
> echo "$myvar"
>
> For anything much trickier, getting the quoting right will be a killer, so
> the helper should probably be a separate bash script.
>
> Picking csh to script it is just wrong, because it has too many missing
> capabilities, isn't predictable enough in how it behaves, doesn't
> necessarily behave as portably as other shells, etc.
> http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/ <
> http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/>
>
>
> > On Mar 8, 2021, at 04:38, Thebest videos 
> wrote:
> >
> >
> > hi Team,
> >
> > Im trying create a csh script.
> > requirement:
> > when i script runs it asks for user input. prompt should wait for 10secs.
> > if not then exit the script.
> > i have solution for bash script where i can use read -t 10 username. but
> i
> > want same in csh
> > ```
> > #!/bin/csh
> > echo -n "username:"
> > set req = $<
> > echo "username is $req"
> > sed -i.bak "/rootpw/s/edjos/$req/" /boot/loader.conf
> > ```
> > and for advance level, the message should look like "prompts end in
> 10(this
> > number should decrease and lively should visible the timeout secs)"
> > ___
> > openindiana-discuss mailing list
> > openindiana-discuss@openindiana.org
> > https://openindiana.org/mailman/listinfo/openindiana-discuss
> >
>
> ___
> openindiana-discuss mailing list
> openindiana-discuss@openindiana.org
> https://openindiana.org/mailman/listinfo/openindiana-discuss
>
___
openindiana-discuss mailing list
openindiana-discuss@openindiana.org
https://openindiana.org/mailman/listinfo/openindiana-discuss


Re: [OpenIndiana-discuss] timeout display for input prompt

2021-03-08 Thread Richard L. Hamilton
If it has to be pure csh (without any helpers), you're probably out of luck, 
because csh is crippled when it comes to scripting.

You could probably use a command substitution on a one-liner of your bash from 
the csh script:

#! /bin/csh
set myvar=`bash -c 'read -t 10 ;echo "${REPLY}"'`
echo "$myvar"

For anything much trickier, getting the quoting right will be a killer, so the 
helper should probably be a separate bash script.

Picking csh to script it is just wrong, because it has too many missing 
capabilities, isn't predictable enough in how it behaves, doesn't necessarily 
behave as portably as other shells, etc.
http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/ 



> On Mar 8, 2021, at 04:38, Thebest videos  wrote:
> 
> 
> hi Team,
> 
> Im trying create a csh script.
> requirement:
> when i script runs it asks for user input. prompt should wait for 10secs.
> if not then exit the script.
> i have solution for bash script where i can use read -t 10 username. but i
> want same in csh
> ```
> #!/bin/csh
> echo -n "username:"
> set req = $<
> echo "username is $req"
> sed -i.bak "/rootpw/s/edjos/$req/" /boot/loader.conf
> ```
> and for advance level, the message should look like "prompts end in 10(this
> number should decrease and lively should visible the timeout secs)"
> ___
> openindiana-discuss mailing list
> openindiana-discuss@openindiana.org
> https://openindiana.org/mailman/listinfo/openindiana-discuss
> 

___
openindiana-discuss mailing list
openindiana-discuss@openindiana.org
https://openindiana.org/mailman/listinfo/openindiana-discuss


[OpenIndiana-discuss] timeout display for input prompt

2021-03-08 Thread Thebest videos
hi Team,

Im trying create a csh script.
requirement:
when i script runs it asks for user input. prompt should wait for 10secs.
if not then exit the script.
i have solution for bash script where i can use read -t 10 username. but i
want same in csh
```
#!/bin/csh
echo -n "username:"
set req = $<
echo "username is $req"
sed -i.bak "/rootpw/s/edjos/$req/" /boot/loader.conf
```
and for advance level, the message should look like "prompts end in 10(this
number should decrease and lively should visible the timeout secs)"
___
openindiana-discuss mailing list
openindiana-discuss@openindiana.org
https://openindiana.org/mailman/listinfo/openindiana-discuss